小编ars*_*had的帖子

当我的应用程序处于后台时,仅当我触摸顶部通知横幅并且在我单击应用程序图标时不工作时才会处理推送通知

我已经实现application:didReceiveRemoteNotification:了在收到推送通知时在我的应用中存储数据.
但是,当我的应用程序处于后台并且收到通知时,仅当我触摸顶部显示的通知横幅时才会存储数据:

相反,如果我触摸应用程序图标以重新打开它,则不会存储通知的内容:

application:didReceiveRemoteNotification: 仅当我将通知横幅推到顶部时才会调用.

我已经使用applicationWillEnterForegrounddidFinishLaunchingWithOptions方法,同时单击应用程序图标并调试其输入applicationWillEnterForeground和控制无处可去.这是didFinishLaunchingWithOptionsapplicationWillEnterForeground和的代码didReceiveRemoteNotification.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    self.isForeground = YES;

    // Let the device know we want to receive push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    storage= [[NSMutableArray alloc]init];
    if (launchOptions …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c apple-push-notifications ios

5
推荐指数
1
解决办法
5885
查看次数