Ios 当应用程序退出或挂起时,处理推送有效负载

Ios 当应用程序退出或挂起时,处理推送有效负载,ios,objective-c,ios8,push-notification,apple-push-notifications,Ios,Objective C,Ios8,Push Notification,Apple Push Notifications,我已经完成了所有的案例,除了一个在接收推送负载时 以下是我的实现: 如果应用程序处于后台、非活动或活动状态,那么我们可以使用此方法接收通知 -(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

我已经完成了所有的案例,除了一个在接收推送负载时

以下是我的实现:

如果应用程序处于后台、非活动或活动状态,那么我们可以使用此方法接收通知

-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
       //Received Notification when the Application is Active, InActive or in Background State. 
       // NOTE : I am Handling below line of code with the Appropriate Conditions using Application States in my Code.
       [self handleNotificationDataWithDictionary:dictionary updateUI:YES];
}
如果应用程序被挂起或退出,那么我们可以在didFinishLaunchingWithOptions方法中接收通知负载,但只有在用户点击通知的情况下

以下是当应用程序退出或挂起并通过点击主屏幕或锁定屏幕上的推送通知打开时接收有效负载的实现

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
       if (launchOptions != nil)
       {
           NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
           if (dictionary != nil)
           {
               [[[UIAlertView alloc] initWithTitle:@"Finish" message:@"Test" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil] show];
               NSLog(@"Launched from push notification: %@", dictionary);
              [self handleNotificationDataWithDictionary:dictionary updateUI:NO];
           }
       }
}
现在,最后一种情况是,当应用程序被挂起时,用户没有使用通知中心打开应用程序,而是通过点击应用程序图标打开应用程序。 在测试代码时,在这种情况下,我无法接收有效负载。我在谷歌上搜索了很多,但没有找到解决这个问题的办法

根据应用程序文档,当应用程序未激活时,我们只能在后台或非活动模式下获取有效负载。那么对于挂起状态如何实现呢


我真的需要这方面的帮助,请发布您的最佳答案,以便对其他人也有用。

简单地说-如果用户点击应用程序图标,您的推送将消失。!无法检索该信息

如果在运行iOS的设备上点击应用程序图标,应用程序将调用相同的方法,但不提供有关通知的信息


hris.to是绝对正确的,如果你想在你的应用程序中定制通知面板,你必须构建一个API,然后再次从服务器获取最新的通知