无声推送消息,如果应用程序是在后台和拔出不容反应 [英] Silent push message, can´t react if app is in background and unplugged

查看:233
本文介绍了无声推送消息,如果应用程序是在后台和拔出不容反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在无声推送消息作出反应。我注册了我的应用程序在我的plist文件的两个后台模式。

I am trying to react on silent push messages. I registered my app for the two background modes in my plist file.

我发送下列JSON我的应用程序:

I am sending the following json to my app:

{
"aps": {
     "content-available": 1
},
"Bla": "Blub"
}

如果我的应用程序是在前台,一切正常。当我收到推我在code执行的功能。如果我的应用程序在背景和插入我的Mac或交流,万物精以及...但是,如果我拔掉我的设备,该设备是没有得到,或者至少我的函数不叫了......这是为什么?

If my app is in foreground, everything works. As I am receiving the push I execute a function in my code. If my app is in background and plugged to my Mac or ac, everythings fine as well... But if I unplug my device, the device is not getting or at least my function is not called anymore...Why is that?

推荐答案

据我所知,沉默的通知工作,他们可以发送的方式,系统可以接收他们,而是对他们根据不同的因素可能不会采取行动。

The way I understand that silent notifications work is that they can be sent, the system may receive them, but may not act upon them depending on different factors.

一个无声的通知是用来给多任务的错觉一个设备是节能的,以及上。我的理解是,有他们系统用于确定它是否应该沿着一个沉默的通知传递给应用程序的几个因素,其中包括:

A silent notification is used to give the illusion of multi-tasking on a device that is power efficient as well. My understanding is that there are a few factors they system uses to determine whether it should pass along a silent notification to an app, these include:


  • 当前网络状况

  • 电流功率水平

  • 应用程序使用。

  • 用户选择

  • 可能的功耗。

在您的情况下,无声的通知在前台,因为你是最重要的应用程序时。用户可以做不涉及内容马上的任务。但所述内容更新可能是有用的。例如与Facebook,我可能会写在墙上的朋友后,也有我的饲料新的故事。它是好的,有一个更新的,而我在做别的事情。

In your case the silent notification is working when in the foreground because you are the foremost application. The user could be doing a task which does not involve the content right away. But the content update could be useful. For example with Facebook, I may be writing a post on a friends wall, there are new stories for my feed. It is nice to have that updated whilst I am doing something else.

有关连接到计算机的情况 - 该设备是充电做后台任务不会是对设备的电池漏

For the case of being connected to your computer - The device is charging doing the background task is not going to be a drain on the device battery.

要给予更详细的信息因素:

To give more details for the factors:

网络条件


  • 如果该设备上的Wi-Fi更可能让网络通话,因为这不是因为能源密集型的使用蜂窝数据。

当前功率级


  • 这也绑在网络条件。

  • 一直在一个点上,相关无线电设备已经在收到通知?

  • 这也可以被捆绑到基于设备历史当前位置。如果该位置被确定为是家,可以假定,该装置是邻近的电源。

  • 时间,也可以在这一个因素。例如什么是设备开始充电的平均时间,是它接近等。

  • 已经连接到电源?
  • 设备

应用程序使用


  • 多久的用户使用你的应用程序,什么花样的使用是有?

  • 曾在一次有意义,让应用程式更新其内容已收到通知?一个可能的例子是,用户很可能使用的应用在未来10分钟到1小时。这可能是有意义的更新内容。但是,如果用户很可能使用的应用程序中的下一个2分钟或2小时。它可能推迟这个,因为它很可能要么是用户启动不久或不会很快使用资源的浪费。

用户选择


  • 用户可以随时选择停止后台数据刷新。

  • 用户可以选择不要让你的应用程序使用蜂窝数据。

  • 虽然你的问题的范围,我认为应该指出,一种无声的通知不应该假定总是通过,不应该是你的应用程序的一个重要组成部分。

可能的功耗


  • 相比其他因素的影响,我不认为这存在的事,但要记住。

  • 当你这样做后台任务,是什么一直喜欢在过去的功耗是多少?

  • 如果你是一个好公民,为动力效率地​​等,你可能会更容易被称为更新。

  • 但是,如果你做这个任务的时候不作为动力尽可能高效的系统视图,你可能不会通知之多。

这些因素不是决定性的,从我可以告诉证明或说明。我建议他们作为基于WWDC会谈,previous后台任务的限制和我自己的假设可能的原因。但我希望他们帮助给一个想法,为什么你的沉默通知在某些情况下,而不是在别人的工作。

These factors are not definitive, proven or stated from what I can tell. I am suggesting them as possible reasons based on WWDC talks, previous background task restrictions and my own assumptions. But I hope they help give an idea why your silent notifications are working in certain instances and not in others.

这篇关于无声推送消息,如果应用程序是在后台和拔出不容反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆