http://www.push-notification.org/
APNS 是什么?
APNS (Android Push Notification Service) 是一种在 android 上轻松实现 push
notification 的功能的解决方案. 只需申请一个 API Key, 经过简单的步骤即可实现 push notification 的功能.
特点:
快速集成:提供一种比C2DM更加快捷的使用方式,避免各种限制.
无需架设服务器:通过使用"云服务",减少额外服务器负担.
通用性强:可以整合各种平台,适用性强,即将推出 html sdk, 使 web app 也可以集成此服务.
耗电少,占用流量少.
获取 API
如何在 Android 应用中使用 Notification ?
a) 在应用中添加 APNS 功能
- 下载 libaray: com_apns.jar
- 将com_apns.jar添加到工程
在工程上右键打开“属性”,选择 “Java Build Path”, 在 Libraries 中选择 “Add External JARs”, 选择下载的
com_apns.jar.
- 接收 push notification
使用BroadcastReceiver接收系统广播:
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(APNService.ON_NOTIFICATION)) {
String str = intent.getStringExtra("data");
//todo, 处理收到的消息
}
}
}
- 启动 Push Notification Service
发送Intent 启动服务,将 chanel Id 以及 此设备的标识 (chanel中唯一表示此设备的字符串) 传递过去:
Intent intent = new Intent(APNService.START);
intent.putExtra("ch", chanel);
intent.putExtra("devId", devId);
startService(intent);
Notes Chanel Id 在申请 API
后,登录开发者页面会看到. devId: chanel 内设备标识,要在chanel内保持唯一.
- 配置 AndroidManifest.xml
...
<application android:icon="@drawable/icon"
...
<service android:name="com.apns.APNSService" android:label="APNS">
<intent-filter>
<action android:name="com.apns.APNService.START" />
<action android:name="com.apns.APNService.STOP" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
<receiver android:name="MyBroadcastReceiver">
<intent-filter>
<action android:name="com.apnsd.APNService.NOTIFICATION" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
b) 发送 Notification 到设备
通过 rest 接口发送
Notification:
http://www.push-notification.org/handlers/apns_v1.php?ch=YourChannelId&devId=xxxxx&msg
=hello world&random=0123&hash=HashCode
ch:Channel Id
devId:接收设备 Id
msg:消息
random:随机数
hash:md5(ch + devId + msg + random + apiKey)
Notes
申请API后,可登录开发者页面使用测试控制台进行API测试.
分享到:
相关推荐
使用android push notification service 实现即时通知
很好的Demo啊
Convert JSON to Android Notification. This is very useful for push notification (GCM). Usage Notification notification = Json2Notification.from(context).with(json).notification(); NotificationManager ...
App 应该将此用户钱包连接到由 Apple Push Notification Service 或 Android Push Notification Service 生成的推送通知令牌 应用程序应该能够以安全的格式将此信息发送到 epns 服务器 应用程序应该
对于iOS,正在使用Apple Push Notification(APN)和对于Android,则使用Google Cloud Messaging(GCM)。如何执行(iOS)? 将push_notification.sql转储到数据库中。 更新webservice / index.php第12行中的数据库...
= 0.271.0.8 0.282.0.1 0.292.0.2 0.30、0.31、0.32> = 2.1.0 > = 0.33安装npm install --save react-native-push-notification react-native link 注意:对于Android,您仍然必须手动更新AndroidManifest.xml(如下...
use Tawba\PushNotification\NotificationService; $notify = new NotificationService(); echo "<pre>"; print_r($notify->send("android", ['testID', ['Test MSG']])); // You can pass android, ios, windows...
iPush - Framewok:registered: 内部 推送技术是一种通信类型,其中服务器在有新信息或通知时向客户端(例如移动设备)发起请求,与传统的拉取技术相比,可以显着节省资源和时间。 理解推送技术的一个非常简单的例子...
= 0.271.0.8 0.282.0.1 0.292.0.2 0.30、0.31、0.32> = 2.1.0 > = 0.33安装npm install --save react-native-push-notification react-native link 注意:对于Android,您仍然必须手动更新AndroidManifest.xml(如下...
= 0.271.0.8 0.282.0.1 0.292.0.2 0.30、0.31、0.32> = 2.1.0 > = 0.33安装npm install --save react-native-push-notification react-native link 注意:对于Android,您仍然必须手动更新AndroidManifest.xml(如下...
测试Najva服务如果要在android应用程序中测试Najva Push Notification Service ,则应: 克隆此项目,然后重命名它的程序包名称。 此可能很有用。 登录后注册该应用程序。(要注册任何应用程序,其程序包名称必须...
步骤1)在cloud.google.com/console/project上创建新项目,然后启用Google Cloud Messaging Service。 记下项目ID,例如。 在我的情况下为941079645636-在客户端使用。 记下我们的本地php服务器使用的api-key =“ ...
//Registering the GCM Service and sending an Android Notification push.RegisterGcmService(new GcmPushChannelSettings("theauthorizationtokenhere")); //Fluent construction of an Android ...
----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...
使用库支持 Apple Push Notification Service。 使用库支持华为设备的。 支持配置。 支持命令行发送单个Android或iOS通知。 支持Web API发送推送通知。 支持或HTTP / 1.1协议。 支持通知队列和多个工作程序。...
– Push notification using OneSignal or Firebase service – Native rating popup (rate my app) – Native alerts Notes: * Being pre-integrated means you won’t need to write a single line of ...
从移动互联网时代开始,即时通讯系统更是加剧演变进化,除了iOS和Android提供全世界范围的Push Notification Service,还形成了各种开放的云推送平台与服务,成为巨头厮杀圈地的战场。在可预见的物联网前景下,相信...
Wiqaytna Android Wiqaytna是摩洛哥官方的暴露通知应用程序。 gradle.properties中的配置 样本配置 ORG="MAR" STORE_URL="<Play>" PRIVACY_URL="<Privacy>" SERVICE_FOREGROUND_NOTIFICATION_ID=771579 SERVICE_...
Web Service提供了各种尿布准的 log data,例如湿度温度变化,尿尿更换提醒(push notification to mobile)。 所有尿布准(Edison board)上的log data,都是透过蓝牙传送到手机(或某中继器的hub),再由手机(或中继的...