Parse warning from didReceiveRemoteNotification:fetchCompletionHandler

后端 未结 5 1958
自闭症患者
自闭症患者 2020-12-12 19:23

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

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


        
相关标签:
5条回答
  • 2020-12-12 19:59

    When you use the new didReceive... method you are expected to do two things:

    1. Add the necessary entry in your plist
    2. Add a completion handler that will handle the event for handling the data

    If you do not want to download any data, you can add this to your didReceive... method

    completionHandler(.NoData)
    
    0 讨论(0)
  • 2020-12-12 20:02

    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.

    0 讨论(0)
  • 2020-12-12 20:12

    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.

    0 讨论(0)
  • In Xcode 6:

    • In the Project Navigator click the project
    • In the Projects and Targets list click the target.
    • Click Capabilities
    • Expand and turn on Background Modes
    • Click Remote Notifications

    This will add the Required background modes key and App downloads content in response to push notifications value to info.plist.

    0 讨论(0)
  • 2020-12-12 20:22

    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/

    0 讨论(0)
提交回复
热议问题