Android/iOS Notification feature

125 篇文章 1 订阅
36 篇文章 0 订阅

notification有3种方案:
轮询 (poll)
长连接 (socket or http: comet)
push notification (c2dm for android, apple notification server for
iPhone, 2者的原理是一样的:push server -> apn -> iPhone -> app installed in
iPhone

Poll: mobile app polls the server for new messagesperiodically

Advantages: easy to implement in CAP server side.

Disadvantage: mobile app has to send a http request to checklatest news periodically (e.g. send a request every 30 mins), it will killdevice battery.

 

Persistent TCP/IP:  mobile app initiates along-lived mostly idle TCP/IP connection with the server and maintains it byoccasionally sending keepalive messages. Whenever there is something new on theserver, it sends a messages to the phone over the TCP connection.

Advantages: Fully real-time updates.

Disadvantages: Hard to implement a reliable service on bothmobile device and the server side.

 

 

C2DM (for Android)/ APNS (for iOS device): they areios and android official recommended push notification solution. message can bepushed to user even if mobile app is not running in device.

APNS introduction: https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9

C2DM introduction: http://www.androidkit.com/cloud-to-device-messaging


push notification的方案(比较全)

http://www.zhishi5.com/jyxx/2012/0119/article_4019.html


android长连接的讨论
http://www.eoeandroid.com/thread-30241-3-1.html

长连接有2种:
1. 基于socket
* socket也有麻烦,因为要知道封装那些消息头,

socket也有好处,能实现同步异步机制,少一个进程
* 自己实现的socket的真正麻烦在于不容易穿透不同类型的网络 ,要达到那一步要做很多工作, 而http在各个层次有很多的支持,容易穿透防火墙,局域网

2. 基于http    (comet)
* http的长连接没多少人用
* 即使是长连接,http也必须要client先发起请求, 在实际应用中有很多限制, 别人做一个http长连接也只是为某些需求提供一个容易实现的方 案,效果并不太好


Comet:基于 HTTP 长连接的“服务器推”技术
http://www.ibm.com/developerworks/cn/web/wa-lo-comet/


pocket长连接与http长连接的比较
http://topic.csdn.net/u/20110227/21/22484864-8d9c-4c4e-8dd9-24ff818ae3f0.html


android是使用Smack, 它是XMPP一个比较流行的客户端lib
smack 源码分析一(android上实现长连接)
http://wangqinghua123.iteye.com/blog/1341355
smack 源码分析- PacketReader (android上实现长连接)
http://wangqinghua123.iteye.com/blog/1341515
smack 源码分析- PacketWriter (android上实现长连接)
http://wangqinghua123.iteye.com/blog/1341473


参考文档:

iOS

偷窥iPhone Push Notification的幕后: http://blog.csdn.net/ydfok/article/details/5732137

再论iPhone Push Notification: http://blog.csdn.net/ydfok/article/details/5732153

当app目前正在运行并在前端,如何处理push notification: http://stackoverflow.com/questions/1554751/how-to-handle-push-notification-if-application-is-already-running

下面这篇文章的"authentication"部分提到了如何把device绑定到user account: http://wiki.remobjects.com/wiki/Adding_Push_Notifications_to_Your_iPhone_Applications_Using_RemObjects_SDK_%28Xcode_%28iOS%29%29

iPhone push notification详解(推荐)

http://blog.csdn.net/kmyhy/article/details/6688370

http://blog.csdn.net/kmyhy/article/details/6739584

http://blog.csdn.net/kmyhy/article/details/6739693

http://blog.csdn.net/kmyhy/article/details/6792855

浅析最烦人的手机消息推送设计模式: http://write.blog.csdn.net/postedit/7329542

iphone push notification 消息推送 : http://blog.csdn.net/linkai5696/article/details/6316929


浅谈iPhone 中Push 功能原理 推送通知
http://mobile.51cto.com/iphone-276485.htm
解析iPhone Push Notification 消息推送 图文详细介绍
http://mobile.51cto.com/iphone-274033.htm
iPhone: 在程序里设置Push
http://mobile.51cto.com/iphone-273845.htm
iPhone: 基于HTTP长连接Server PUSH
http://mobile.51cto.com/iphone-278408.htm
iPhone 搭建PHP版Push服务器 实例操作
http://mobile.51cto.com/iphone-273924.htm





Android

Android notification 官方文档:

http://developer.android.com/guide/topics/ui/notifiers/index.html

http://developer.android.com/guide/topics/ui/notifiers/toasts.html

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

Android Push Notification推播機制系列文章: http://lp43.blogspot.com/2012/02/android-push-notification.html

Android使用asynctask来做notification listener的问题: http://stackoverflow.com/questions/6143131/how-to-wake-up-start-not-running-app-from-c2dm-listener-on-android

不使用c2dm的android push notification方案: http://hi.baidu.com/heagle018/blog/item/f299029d36883a7654fb9654.html










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值