2017-03-09 52 views
0

我有一个成功发送通知的自定义通知服务,但在用户单击通知时从不会调用didReceiveRemoteNotification。该应用程序将打开到最后一个状态,我试图深入链接到应用程序中的特定场景。从自定义服务发送邮件时未调用didReceiveRemoteNotification

以我didFinishLaunchingWithOptions我通过调用此函数”

FUNC registerForPushNotifications(应用:UIApplication的)注册的通知类型 { 让notificationSettings = UIUserNotificationSettings(类型:[.badge,.sound,.alert] ,类别:无) UIApplication.shared.registerUserNotificationSettings(notificationSettings) }

我登记我的设备与被叫至 didRegisterForRemoteNotificationsWithDevi后端服务ceToken功能

接下来,我有我的didregister功能

FUNC应用(_应用:UIApplication的,didRegister notificationSettings:UIUserNotificationSettings){ UIApplication.shared.registerForRemoteNotifications() }

最后,我有didReceiveRemoteNotification当我点击通知时,我预计会被调用。

FUNC应用(_应用:UIApplication的,didReceiveRemoteNotification用户信息:AnyHashable:任何]){ }

的XML正在被贴到我的后端服务是相当简单的,似乎是按预期工作: { “观众”:{ “ios_channel”: “e06b9r8r-ffce-4fa6-92ec-123456789” }, “通知”:{ “IOS”:{ “警告”: “测试音发送”, “title”:“Test Alert”, “sound”:“default” }} , “DEVICE_TYPEs的”:[ “IOS” ] }

如果任何人有输入至于为什么didReceiveRemoteNotification func被不叫,将不胜感激。

+0

我在发布后不久就解决了这个问题。我使用的是Urban Airship v1.0,UA库会自动整合到应用程序中,拦截任何回拨到应用程序的电话。要解决这个问题,请在AirshipConfig.plist文件或UAConfig中将“automaticSetupEnabled”添加到NO。 UA在此解释此更改:http://docs.urbanairship.com/platform/ios.html#automatic-integration – Liedl

回答

0

didReceiveRemoteNotification仅在您的应用程序打开时触发。要响应用户点击通知,您需要检查参数didFinishLaunching中的UIApplicationLaunchOptionsRemoteNotificationKey值。

相关问题