【问题标题】:iOS Silent push notification is not working if I killed app manually [duplicate]如果我手动终止应用程序,iOS 静默推送通知将不起作用 [重复]
【发布时间】:2014-02-09 05:58:35
【问题描述】:

我已经实现了静默推送通知。如果我手动杀死应用程序,它就不起作用。 在收到静默推送通知后,我调用了一个将数据发送到服务器的函数。

这是我的静音推送通知代码

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


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

handler(UIBackgroundFetchResultNewData);
}

请指导我。

更新: - 如果用户在应用切换器中手动终止应用,则无法通过静默通知或后台获取启动应用。要获得通知,用户必须重新启动应用程序。如果有人需要激活应用程序,那么应该为该应用程序启用 PushKit + VOIP,例如 whatsapp,请参阅以下链接 https://zeropush.com/guide/guide-to-pushkit-and-voip

【问题讨论】:

  • 查看上述问题的答案,可能是用户手动杀死应用时的错误。
  • @nikBhosale 您是否收到有关此问题的任何更新?
  • @urmi,如果用户强制退出,系统不会自动启动您的应用程序。请阅读发布的更新。谢谢。
  • @nikBhosale 谢谢。我明白你的意思了。我可以使用 VoIP 启动我的应用程序以进行推送通知吗?

标签: ios apple-push-notifications


【解决方案1】:

didReceiveRemoteNotification 仅在运行时调用应用程序且应用程序处于后台状态,而不是应用程序未运行状态,此时您会收到这样的通知

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 ...............
 ...............
 UILocalNotification *localNotif =[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
 if (localNotif) {

     NSLog(@"load notifiation *******");
    // Perform your actions
}

    return YES;
}

【讨论】:

  • iOS7 中添加了静默处理推送通知。上面写着If your app is suspended or not running, the system wakes up or launches your app and puts it into the background running state before calling the method.
  • 感谢您的回复。我会试试这个,让你知道它是否有效。
  • @NANNAV.. 我试过了,但它仍然不适合我。
  • 如果应用未运行,是否有其他方法可以调用 Web 服务?
  • @JanakNirmal 如果您继续阅读,它会说:However, the system does not automatically launch your app if the user has force-quit it
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-24
  • 1970-01-01
  • 2013-10-14
  • 1970-01-01
  • 2016-10-18
  • 1970-01-01
相关资源
最近更新 更多