<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-31  評論-14  文章-0  trackbacks-0

    APNS 是什么?

    APNS (Android Push Notification Service) 是一種在 android 上輕松實現 push notification 的功能的解決方案. 只需申請一個 API Key, 經過簡單的步驟即可實現 push notification 的功能.

    特點:

  • 快速集成:提供一種比C2DM更加快捷的使用方式,避免各種限制.
  • 無需架設服務器:通過使用"云服務",減少額外服務器負擔.
  • 可以同時推送消息到網站頁面,android 手機
  • 耗電少,占用流量少.
  •  

    http://zen-mobi.com/get_api_key.php獲取apikey

    如何在 Android 應用中使用 Notification ?

    a) 在應用中添加 APNS 功能

    1. 下載 libaray: com_apns.jar
    2. 將com_apns.jar添加到工程
    3. 在工程上右鍵打開“屬性”,選擇 “Java Build Path”, 在 Libraries 中選擇 “Add External JARs”, 選擇下載的 com_apns.jar.

    4. 接收 push notification
    5. 使用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, 處理收到的消息 		 }  	} } 
    6. 啟動 Push Notification Service
    7. 發送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內保持唯一.
    8. 配置 AndroidManifest.xml
    9. ... <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)
    posted on 2012-07-21 22:15 zhanghu198901 閱讀(1745) 評論(1)  編輯  收藏

    評論:
    # re: android push notification serfice android中的push機制[未登錄] 2014-08-26 16:11 |
    啊啊   回復  更多評論
      

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 中文毛片无遮挡高潮免费| 日韩精品久久久久久免费| 免费夜色污私人影院网站电影 | 久久精品免费全国观看国产| 成人免费视频观看无遮挡| 成人免费一区二区三区在线观看| 在线观看免费宅男视频| 456亚洲人成影院在线观| 好男人资源在线WWW免费| 成人免费看黄20分钟| 亚洲熟妇av午夜无码不卡 | 午夜亚洲WWW湿好爽| 69影院毛片免费观看视频在线| 国产高清免费的视频| 久久久久久亚洲精品| 尤物视频在线免费观看| 免费高清小黄站在线观看| 色婷婷亚洲十月十月色天| 处破女第一次亚洲18分钟| 1000部禁片黄的免费看| 亚洲不卡在线观看| 性xxxxx大片免费视频| 亚洲性在线看高清h片| 亚洲人成网亚洲欧洲无码| 91在线老王精品免费播放| 亚洲午夜未满十八勿入网站2| 亚洲国产成人久久一区二区三区| 免费成人激情视频| 亚洲av日韩av无码黑人| xxxxx免费视频| 亚洲人成网站免费播放| 亚洲女同成av人片在线观看| 日韩插啊免费视频在线观看| 亚洲视频在线观看2018| 99免费观看视频| 亚洲人成网站18禁止| 亚洲AV无码第一区二区三区| 182tv免费视频在线观看| 亚洲午夜久久久久久噜噜噜| 中文字幕免费在线| 亚洲AV无码专区在线厂|