相关疑难解决方法(0)

在后台使用didReceiveRemoteNotification

这样的问题已被多次询问,但我有一些特定的情况正在发生.

当我的应用程序处于活动状态并且我收到PUSH消息时,我成功地能够解析自定义有效负载等.

但是当我的应用程序在后台并且PUSH到达时,用户必须单击"查看/打开"按钮才能获得didReceiveRemoteNotification被叫,然后didFinishLaunchingWithOptions被调用.

我需要让我的应用程序决定是否必须在后台提示用户使用UIAlert,或者根据某些本地设置禁止推送消息.

任何帮助,将不胜感激,

iphone apple-push-notifications ios4

52
推荐指数
4
解决办法
7万
查看次数

iOS 10静音推送通知不会触发后台应用程序

我有一个应用程序,我正在尝试接收和处理SILENT推送通知.

我正在注册APN如下:

UNUserNotificationCenter.currentNotificationCenter().delegate = self
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert]) {(granted, error) in
    if granted {
        application.registerForRemoteNotifications()
    }
}
Run Code Online (Sandbox Code Playgroud)

实现:

func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
    // Handle notification
}

func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {
    // Handle notification
}
Run Code Online (Sandbox Code Playgroud)

该应用程序有UIBackgroundModes fetchremote-notification

APN内容如下:

{
    "aps":{
        "content-available":1,
        "badge":0
    },
    "action":"shareDelete",
    "shareId":633
}
Run Code Online (Sandbox Code Playgroud)

当应用程序位于前台时,userNotificationCenter(centre:withCompletionHandler:willPresentNotification)会在收到通知时触发,但是当应用程序背景化时,没有任何反应.

我可以通过更改徽章编号看到收到的APN,但在应用程序中没有触发任何内容.

我错过了什么?

(也在Apple开发论坛上询问)

apple-push-notifications ios10

14
推荐指数
2
解决办法
3631
查看次数

标签 统计

apple-push-notifications ×2

ios10 ×1

ios4 ×1

iphone ×1