Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse warning from didReceiveRemoteNotification:fetchCompletionHandler

I am getting an error after adding this code from parse.com:

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    if (application.applicationState == UIApplicationStateInactive) {
        [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
    }
}

I don't really understand what is going on, but I am getting this warning in the log:

You've implemented -[ application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.

I think adding in your plist file UIBackgroundModes - remote-notification would fix the problem,

But when I do that, it changes the words to the follow:

Required Background Modes -> App downloads content in response to push notifications

Which my app doesn't do, so I am confused as to why I am doing this in the first place.

like image 791
Arian Faurtosh Avatar asked Nov 15 '13 19:11

Arian Faurtosh


3 Answers

If you don't want to manually add key in your .plist file then here's a graphical version of @MurraySagal's answer, follow the steps from 1 to 7 and you'll be done. :)

enter image description here

Note: If you can't read out the steps, you can zoom out your current tab by using combination of Command++ (for zoom in) and Command+- (for zoom out). If Command won't work, you can try with Ctrl.

like image 129
Hemang Avatar answered Nov 19 '22 08:11

Hemang


I think @djshiow is not solving your problem.

You need to add the following in your info.plist file:

remote-notification

1) Add a new row and, on the left column, select Required background modes.

2) On Item 0 row, click on the right column and type: remote-notification. Press Enter.

Source: http://hayageek.com/ios-silent-push-notifications/

like image 34
jomafer Avatar answered Nov 19 '22 08:11

jomafer


If you don't intend to fetch data in response to a remote notification I think you can implement this delegate method:

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

e.g.

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if (application.applicationState == UIApplicationStateInactive) {
        [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
    }
}

instead of the current one you're using.

like image 31
djshiow Avatar answered Nov 19 '22 09:11

djshiow