推送通知 - 有效负载中缺少警报

时间:2015-01-17 18:12:25

标签: ios iphone apple-push-notifications

这是我userInfo

中的didReceiveRemoteNotification
    aps =     {
        badge = 2;
        sound = default;
    };
    u = "{\"custom\":{\"redirectlink\":\"groupdetail.html?groupid=314416&selectedtabid=5\"}}";
} 

此处缺少警告字段。这是我试图处理丢失警报的原因:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
   [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
    NSMutableDictionary *pushDict = [NSMutableDictionary dictionaryWithDictionary:[userInfo objectForKey:@"aps"] ];
    BOOL isSilentPush = [[pushDict objectForKey:@"content-available"] boolValue];
    [pushDict setObject:@"You have a notification" forKey:@"alert"];
    NSMutableDictionary * mut = [NSMutableDictionary dictionaryWithDictionary:userInfo]; //[userInfo copy];
    [mut setObject:pushDict forKey:@"aps"];
    //[mut setObject:@"5@" forKey:@"p"];
    if (isSilentPush) {
        NSLog(@"Silent push notification:%@", userInfo);

        //load content here

        // must call completionHandler
        completionHandler(UIBackgroundFetchResultNewData);
    }
    else {
        [[PushNotificationManager pushManager] handlePushReceived:mut];

        // must call completionHandler
        completionHandler(UIBackgroundFetchResultNoData);
    }
} 

但这不会生成横幅通知。仅生成徽章,声音和警报 我知道这应该从服务器端处理而不是从iOS应用程序处理,但是服务器人员将在2天后回来并且我有一个演示要显示。

0 个答案:

没有答案