试图记录"警告"来自推送通知userInfo字典但是变为空

时间:2015-03-11 17:24:28

标签: ios objective-c push-notification apple-push-notifications

我的AppDelegate.m中有这个方法:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground  )
    {
        //restore push
        [[NSNotificationCenter defaultCenter] postNotificationName:@"appRestorePush" object:nil];

    }

    else {

        //push for when the app is open
        [[NSNotificationCenter defaultCenter] postNotificationName:@"appOpenPush" object:nil];
        NSString *alert = [userInfo objectForKey:@"alert"];
        NSLog(@"%@",alert);
    }


}

我想在控制台中记录警报但由于某种原因我得到了null。发送的任何推送消息都使用此代码:

//set the message and data
            NSString *pushMessage = [NSString stringWithFormat:@"Message! %@ %@",message, self.currentUser.username];
            NSDictionary *pushData = @{@"alert": pushMessage, @"badge": @0, @"sound": @"alert.wav"};
            PFPush *push = [[PFPush alloc] init];
            [push setQuery:pushQuery];
            [push setData:pushData];

“警告”中应该有一个字符串。有什么想法我为什么会变空?

0 个答案:

没有答案