<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 上輕松實現(xiàn) push notification 的功能的解決方案. 只需申請一個 API Key, 經(jīng)過簡單的步驟即可實現(xiàn) push notification 的功能.

    特點:

  • 快速集成:提供一種比C2DM更加快捷的使用方式,避免各種限制.
  • 無需架設服務器:通過使用"云服務",減少額外服務器負擔.
  • 可以同時推送消息到網(wǎng)站頁面,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接收系統(tǒng)廣播:  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. 發(fā)送Intent 啟動服務,將 chanel Id 以及 此設備的標識 (chanel中唯一表示此設備的字符串) 傳遞過去:       Intent intent = new Intent(APNService.START);     intent.putExtra("ch", chanel);     intent.putExtra("devId", devId);     startService(intent); 
      Notes Chanel Id 在申請 API 后,登錄開發(fā)者頁面會看到. 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) 發(fā)送 Notification 到設備

    通過 rest 接口發(fā)送 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:隨機數(shù) hash:md5(ch + devId + msg + random + apiKey)
    posted on 2012-07-21 22:15 zhanghu198901 閱讀(1749) 評論(1)  編輯  收藏

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

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


    網(wǎng)站導航:
     
    主站蜘蛛池模板: av网站免费线看| 亚洲精品宾馆在线精品酒店| 一区二区三区AV高清免费波多| 91亚洲va在线天线va天堂va国产 | 亚洲AV无码一区二三区| 亚洲精品中文字幕无码A片老| 三年片在线观看免费大全| 免费观看日本污污ww网站一区| 亚洲中文字幕无码专区 | 亚洲春色在线观看| 最近免费最新高清中文字幕韩国| 日本一区免费电影| 亚洲国产成人久久综合碰碰动漫3d| 中文字幕免费人成乱码中国| 亚洲精品夜夜夜妓女网| 国产精成人品日日拍夜夜免费| 久久久久亚洲av无码专区| 国产91色综合久久免费| 亚洲一本到无码av中文字幕| 国产高清在线精品免费软件| 2022年亚洲午夜一区二区福利 | 国产在线观看麻豆91精品免费 | 春意影院午夜爽爽爽免费| 久久精品国产亚洲Aⅴ蜜臀色欲| 国产成人无码区免费内射一片色欲| 色婷婷亚洲十月十月色天| 青青青免费国产在线视频小草| 国产精品无码亚洲精品2021| 最近免费中文字幕高清大全| 亚洲精华国产精华精华液| 亚洲日韩人妻第一页| 久久久久国产精品免费看| 国产精品亚洲mnbav网站| 国产麻豆一精品一AV一免费| 亚洲AV无码一区二区三区人| 免费的全黄一级录像带| 亚洲男人的天堂久久精品| 免费在线精品视频| 美女露100%胸无遮挡免费观看| AV免费网址在线观看| 特级做a爰片毛片免费看|