【发布时间】:2018-01-27 11:35:39
【问题描述】:
我的推送通知包含自定义数据,有助于在单击通知时将应用程序路由到正确的位置。如果应用程序打开或在后台运行,这些工作正常,但在应用程序关闭时不起作用。通知会打开应用程序,但我的代码没有检测到引用的通知事件,因此我可以路由它。 我在 AppDelegate.m 中有这个
#ifndef DISABLE_PUSH_NOTIFICATIONS
- (void) application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
// re-post ( broadcast )
NSString* token = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@"<" withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString:@" " withString:@""];
[[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token];
}
- (void) application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
// re-post ( broadcast )
[[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error];
}
#endif
我有这个 JS 代码可以在我的应用程序中捕获通知
document.addEventListener('push-notification', function(event) {
//get the notification payload
console.log("incoming PUSH notification!")
console.log(event);
factory.reactToIncomingPushNotification(event)
});
我的问题是应用冷启动后如何在应用中引用通知事件?
我有一个以 pushwoosh 作为提供者的 cordova/ionic 应用程序。我正在IOS上测试。
【问题讨论】:
标签: ios cordova push-notification pushwoosh