iOS推送服务:是否可能出现无形的推送通知? [英] iOS push services: is an invisible push notification possible?

查看:82
本文介绍了iOS推送服务:是否可能出现无形的推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个iPhone应用程序,该应用程序依赖于在线数据库中的数据.

I'm building a iPhone application which depends data from an online database.

要更新应用程序中的数据,我可以在一定的时间间隔内检查是否需要更新,但是如果我可以使用推送服务向应用程序发送通知,让它知道是时候进行更新了,那就更酷了.更新.

To update the data in the app i could check at a certain time interval if an update is necessary but it is way cooler if i could use a push services which sends a notification to the app letting it know it is time for an update.

我在这里不是在谈论可见的推送通知,而只是在我的应用中触发更新方法的不可见的推送通知.

i'm not talking visible push notifications here, just a invisible push notification to fire the update method in my app.

是否有执行此操作的标准方法?我是否可以为此目的使用Apple的推送通知服务?

Is there a standard way to do this or could i use apple's push notification services for this purpose ?

换句话说:我现在正在使用pull来获取更新,是否有一种推送方法可以让我的应用程序后端知道该进行更新了?

如果不可能,那么更新的时间间隔将是一个好的时间间隔(如果没有更新,则为0.03 kb).每30秒检查一次是否足够?

And if it is impossible, what would be good time interval for the update (0.03 kb if there are no updates). Is it to much to check it every 30 seconds ?

推荐答案

使用Apple Push Notification Service(APNS),您可以获取以下任意组合:

With Apple Push Notification Service (APNS) you can get ANY combination of:

  • 要向用户显示的警报消息
  • 用于标记应用程序图标的数字
  • 播放声音

当我说任何话时,我的意思是没有警报,没有徽章也没有声音.即使关闭了应用程序(但至少执行了一次,用于注册到通知服务中),远程通知仍然可用,iOS负有管理推送和唤醒应用程序的责任.

When I say any I mean that no alert, no badge and no sound are also possible. Remote notifications are available even if the application is closed (but at least once executed, for register into the notification service), iOS has the debt of manage the push and wake up your application.

如果要使用APNS,则需要

If you want to use APNS you need

  • Web服务器(将生成推送)
  • Web服务器的CSR
  • 信任您的服务器的Apple证书(这是CSR的原因)
  • 具有为通知配置的应用程序ID的iOS应用程序

在iOS设置门户的应用程序ID"部分的如何"选项卡中,详细介绍了与CSR和信任服务器有关的所有内容.尝试此链接.

Everything related with CSR and trusting your server is detailed in the iOS provisioning portal, "App ID" section, "How to" tab. Try this link.

在您的Web服务器中,必须托管APNS提供者,该提供者将执行以下两项操作:

In your web server must be hosted the APNS provider who will do these two actions:

  • 注册一个令牌,以标识具体的iOS设备上的具体安装.该令牌是为Apple APNS生成的,将由您的应用发送给提供商.

  • Register a token identifying a concrete installation on a concrete iOS device. This token is generated for the Apple APNS and will be sended to the Provider by your app.

生成推送通知:将从您的提供商发送到Apple APNS,Apple APNS将交付到您的应用程序(具有警报和/或徽章和/或声音和/或静音模式)

Generate push notifications: Will be sended from your provider to Apple APNS, an Apple APNS will delivery to your app (with an alert and/or badge and/or sound and/or silence mode)

APNS通知将使用远程通知系统传递到您的应用.

The APNS notification will be delivered to your app using the Remote Notification System.

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

您可以查看轻松的APNS应用程序委托

作为提供者,您可以使用自己开发的资源,也可以使用/修改已经可以下载的任何人,例如

As a provider you can use your own developed or you can use/modify anyone already downloadable like

  • Easy APNS
  • Java APNS
  • Javapns
  • etc

因此答案是肯定的,这是可能的.使用轻松的APNS esamples ,推送生成必须看起来像像这样:

So the answer is YES, it is possible. Using Easy APNS esamples, the push generation must look like this:

$apns->newMessage(1);
$apns->addMessageCustom('acme2', array('bang', 'whiz'));
$apns->queueMessage();

这篇关于iOS推送服务:是否可能出现无形的推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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