[英]didFinishLaunchingWithOptions remote notification empty on App Launch
I am implementing Push Notification in my app, and everything works just fine when the app is open: when a Notification is received, my method [self processRemoteNotification:pushNotification]
fires off as expected. 我正在我的应用程序中实现推送通知,当打开应用程序时一切正常:当收到通知时,我的方法
[self processRemoteNotification:pushNotification]
会按预期触发。 Now I want the same method to be called, when the app is receiving a remote notification, when it is NOT running. 现在,当应用程序接收到远程通知且未运行时,我希望调用相同的方法。 For that, I have the following code:
为此,我有以下代码:
- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary* pushNotification =
[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (pushNotification) {
[self processRemoteNotification:pushNotification];
}
return YES;
}
I'm not really sure how to test this though. 我不太确定该如何测试。
What I did is 我所做的是
In the above method, I have put a break point. 在上面的方法中,我已经设置了一个断点。 Somehow, the condition
if (pushNotification)
is not met, and my [self processRemoteNotification:pushNotification]
is not fired. 不知何故,
if (pushNotification)
条件if (pushNotification)
,并且未触发我的[self processRemoteNotification:pushNotification]
。
What am I doing wrong? 我究竟做错了什么?
您需要通过在锁定屏幕上或通知中心从左向右滑动通知来启动应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.