如果我手动杀死应用程序,iOS无声推动通知不起作用



我已经实现了无声推动通知。如果我手动杀死应用程序,那就不起作用。获得无声推送通知后,我打电话给一个将数据发送到服务器的功能。

这是我无声推动通知的代码

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{

NSLog(@"didReceiveRemoteNotification fetchCompletionHandler...........");
[MyviewController SendDataFunction];
handler(UIBackgroundFetchResultNewData);
}

请指导我。

更新: - 如果用户在App Switcher中手动杀死了应用程序,则无法通过无声通知或背景获取启动应用程序。要获得通知,用户必须重新启动该应用程序。而且,如果有人需要激活应用程序,那么应该为该应用程序启用PushKit VoIP,例如WhatsApp,请参阅以下链接https://zeropush.com/guide/guide-to-pushkit-and-voip

didReceivereMoteNotification 仅在运行和在后台状态下运行时称为应用,它不称为应用程序不运行状态,当时您会收到这样的通知

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 ...............
 ...............
 UILocalNotification *localNotif =[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
 if (localNotif) {
     NSLog(@"load notifiation *******");
    // Perform your actions
}
    return YES;
}

最新更新