简体   繁体   English

didFinishLaunchingWithOptions远程通知在应用启动时为空

[英]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 我所做的是

  1. kill the app on the device 杀死设备上的应用
  2. send a notification to the app 向应用发送通知
  3. wait until the device displays a badge & notification 等到设备显示徽章和通知
  4. start the app on the device from Xcode 从Xcode在设备上启动应用程序

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.

相关问题 杀死切换器中的应用程序,然后从本地通知启动它,didFinishLaunchingWithOptions中的launchOptions为nil - kill a app in switcher, then launch it from a local notification, launchOptions is nil in didFinishLaunchingWithOptions 远程通知“ application:didFinishLaunchingWithOptions:”方法未调用 - Remote Notification 'application:didFinishLaunchingWithOptions:' method not called 远程通知不会在后台启动应用程序 - remote notification does not launch app in background 是否有没有将应用程序启动到后台的无提示远程通知? - Is there a silent remote notification that does not launch the app into background? 从网址架构启动应用程序时未调用didFinishLaunchingWithOptions - didFinishLaunchingWithOptions not called when app launch from url schema 如何在App在前台运行时忽略远程通知,但在单击通知启动App时处理它? - How to ignore remote notification when App runs in the foreground but handle it when clicking the notification to launch the App? 当应用程序从推送通知打开时,是否调用didFinishLaunchingWithOptions - Is didFinishLaunchingWithOptions called when app opens from push notification 当应用程序通过远程推送启动didFinishLaunchingWithOptions时延迟openURL - Delaying openURL when app launched via remote push through didFinishLaunchingWithOptions 从主屏幕启动应用程序无法获得远程推送有效负载? 但是从通知中心启动工作 - Launch app from homescreen can't get remote push payload? But launch from Notification Center works 推送通知 -didFinishLaunchingWithOptions - Push Notification -didFinishLaunchingWithOptions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM