标签: remote-notifications

iOS中的远程通知和静默通知有什么区别?

当我阅读Apple Docs时,他们提到了3种类型的通知:本地,远程和静默.

可以从应用程序本地发送的名称推断本地通知.

但是,其他两种类型的区别是什么?

push-notification apple-push-notifications ios remote-notifications silent-notification

41
推荐指数
2
解决办法
2万
查看次数

如何启用/禁用应用程序的推送通知?

在我的应用程序中,我想从我的应用程序本身的设置页面启用/禁用推送通知.任何人都可以建议我从应用程序打开/关闭通知中心的应用程序状态的解决方案?

xcode push-notification ios remote-notifications unusernotificationcenter

25
推荐指数
2
解决办法
3万
查看次数

APNS生产和开发环境之间didReceiveRemoteNotification的差异行为

我注意到APNS生产和开发环境之间的didReceiveRemoteNotification的不同行为.

在开发模式(使用开发配置文件构建)中,当用户点击通知时,将调用此方法.在背景和活动状态.

但是在生产模式(使用adhoc配置配置文件构建)中,当用户点击通知时,如果应用程序处于后台或未处于活动状态,但当应用程序处于活动状态时,此方法在接收通知时会立即调用,则会调用此方法.

任何人都可以帮我理解这种不同的行为吗?

我希望我的用户在点击通知(处于活动状态)时重定向到不同的屏幕,但由于这种行为,他会自动重定向到其他屏幕.

push-notification apple-push-notifications ios remote-notifications

17
推荐指数
1
解决办法
414
查看次数

如何清除应用中的远程通知?

从iPhone屏幕顶部向下滑动时,有没有办法从通知横幅中清除远程通知.我尝试将徽章编号设置为零:

application.applicationIconBadgeNumber = 0 
Run Code Online (Sandbox Code Playgroud)

在代表中didFinishLaunchingWithOptions,didReceiveRemoteNotification但是,它没有清除通知.谢谢.

ios swift remote-notifications

16
推荐指数
2
解决办法
2万
查看次数

从通知服务扩展访问应用程序代码

通知服务扩展在将远程通知传递给用户之前修改其内容。例如,如果远程通知包含图像 URL,则可以使用通知服务扩展来获取图像并将其显示在通知内容中。

但是如何访问通知服务扩展中的实际应用程序代码?假设我在应用程序代码中有一个swift 类,我可以在通知服务扩展DataAccess中访问该类吗?

编辑:有些人建议将应用程序代码添加到服务扩展中,这不适用于我的情况。

ios swift remote-notifications unnotificationserviceextension

10
推荐指数
1
解决办法
2798
查看次数

iOS/FCM - 如何使用Payload中的图像名称将XCAsset文件夹中的图像显示为通知附件?

我正致力于通过FCM发送的天气应用程序的Rich Notification.

首先,我想通知您,我的通知是通过APNS和FCM成功发送和接收的.

我正在使用PusherPostman来测试一切.

CONTEXT

这是我发送的有效负载 Postman

{
    "to": "/topics/03772",
    "content_available": true,
    "mutable_content": true,
    "priority": "high",

    "notification": {
        "title": "Daily forecast",
        "body": "Blue sky, no clouds",
        "sound": "default",
        "click_action": "weather"
    },
    "data": {
        "timestamp": "1506103200",
        "code": "03772",
        "city": "London",
        "attch": "7a",
        "t": "15?",
    }
}
Run Code Online (Sandbox Code Playgroud)

我喜欢这种Payload格式,我知道它有效,对我来说很清楚,也很容易理解.

解释:

用户可以通过将城市添加为收藏城市来订阅主题.主题是城市代码.

data部分是从服务器发送的天气数据.

这是我的didReceive方法:

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) …
Run Code Online (Sandbox Code Playgroud)

firebase swift remote-notifications firebase-cloud-messaging

9
推荐指数
1
解决办法
976
查看次数

推送通知未显示在Android前景中

我已经react-native-fcm在Android和iPhone中用于远程通知。

反应本机

在Android前景中,我无法在通知栏中获得远程通知。

在后台模式下,我能够成功获取通知,但在前台却不能。

Android Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.nusape">

    <application>

        <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
        <receiver android:enabled="true" android:exported="true"  android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
        <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="my_default_channel"/>

        <service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>



       <activity android:launchMode="singleTop" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="fcm.ACTION.HELLO" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

App.js …

android react-native remote-notifications firebase-cloud-messaging react-native-firebase

8
推荐指数
1
解决办法
4015
查看次数

如何从我的应用启用/禁用推送通知

我正在使用具有推送通知属性的应用程序.我应该我的应用程序中启用/禁用推送通知权限,而无需转到iPhone设置.

有没有办法实现呢?

我搜索了很多,但我找不到任何正确的方法来实现它.

有帮助吗?

objective-c push-notification ios swift remote-notifications

5
推荐指数
1
解决办法
1795
查看次数

我应该在收到有效负载后更新我的应用吗 或者我应该通过允许它自己下载来更新它?

当您的iPhone收到WhatsApp/Telegram推送通知时,例如

wife:
"buy pizza"
Run Code Online (Sandbox Code Playgroud)

问题1:应用程序是否必须自行下载/接收.这是手机上弹出的横幅必须为自己下载+我的Whatsapp/Telegram必须再次自行下载?

我的朋友回答说:

推送通知可以将消息作为有效负载.您的应用可以提取并动态插入到对话中而无需另外请求 - 我之前已经这样做了.让它感觉更加快捷.缺点是您不能保证推送将以正确的顺序(或根本没有)到达.

但我不相信,从语义的角度来看,推送通知不应该真正更新你的应用程序.如果他们这样做将是一种滥用......他们应该只通知您的应用程序更新,然后允许您通过下载任何已提供的新内容来自行更新.

因此,要查看顶级公司及其应用是否正在应用我的朋友建议我使用3个应用(Gmail,WhatsApp,Telegram)进行了一些实验:

我关闭了Wifi,但保留了蜂窝数据,然后我也禁用了应用程序使用Cellular数据的访问权限.

在此输入图像描述

然后我有人给我发了一条消息/电子邮件:这是我的结果:

电报::我收到警报(发件人+第一行).但是一旦我打开应用程序(或点击通知),它就没有我的新消息或任何东西.

但是,如果允许Telegram访问互联网...它会在后台下载消息...即如果我遵循以下顺序:我是wifi或没有互联网限制的蜂窝数据 - >收到通知 - >转互联网完全关闭,但然后转到应用程序:我会在那里看到完整的消息/正文.

Gmail:我收到提醒(有预览主题/发件人/正文)但是一旦我打开应用程序,它就没有我的新消息或任何东西.

如果Gmail应用程序被允许访问互联网......那么与Telegram相反:只有在打开应用程序本身之前,它才会下载/更新Gmail中的电子邮件.我猜Gmail没有content-available设置,1但Telegram设置为1

WhatsApp:我什么都没得到.

没有互动发生在接到通知......这只有当应用程序被下载情况本身.

我的结论是:

没有互动发生在接到通知......这只有当应用程序被下载情况本身独立于有效载荷的到来.

Gmail和Telegram正在进行冗余下载,基本上不够智能,我的朋友建议或者没有收到电子邮件/消息的风险太大,最好安全一点:thinking_face:

问题2:这个结论是否正确?

apple-push-notifications ios swift remote-notifications silent-notification

5
推荐指数
1
解决办法
322
查看次数

关闭应用程序时的iOS通知

我有一个ios应用程序,从服务器发送通知时我将远程通知发送到哪里,我正在设置内容-available = 1声音=“” 在IOS设备上使用时

applicaiton(didReceiveRemoteNotification:fetchCompletionHandler :)

我看到应用程序在后台运行时到达此方法,但是在关闭应用程序时未调用此方法,但是在关闭应用程序时未调用该方法

applicaiton(didReceiveRemoteNotification:fetchCompletionHandler :)

我在此方法中的处理程序是

        let userInfoDic = userInfo as NSDictionary as? [String: Any]
        let cato = userInfoDic?["cato"] as? String
if cato == "message" {
            let state: UIApplicationState = UIApplication.shared.applicationState
            if state == .active{
                print("Application is Active Socket IO will Handle This")
            }else{
                let apnMessage = userInfoDic?["apnMessage"] as? [String: Any]
                if (apnMessage == nil){
                    print("Error Fetching Message")
                }else{
                let count = UserDefaults.standard.integer(forKey:"TotalUnredMessage")

                    DispatchQueue.main.async {
                        UIApplication.shared.applicationIconBadgeNumber = count + 1
                    }
                    UserDefaults.standard.set(count, forKey: …
Run Code Online (Sandbox Code Playgroud)

apn push-notification ios remote-notifications

5
推荐指数
1
解决办法
8811
查看次数