2014年6月25日 星期三

Android-Parse推波功能

已更新(2015/06/24)位置

先去官方網站下載Android SDK : 下載連結














將jar放入專案底下的lib並加入jar檔案























在MainActivity.java放Key

Parse.initialize(this, "Your App Key", "Your Client Key");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseAnalytics.trackAppOpened(getIntent());
















在AndroidManifest.xml加入權限

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
  IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
    android:name="com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" />





並且把service服務放在</application>之前


<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
  <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
    <action android:name="android.intent.action.USER_PRESENT" />
  </intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
    android:permission="com.google.android.c2dm.permission.SEND">
  <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <!--
      IMPORTANT: Change "com.parse.tutorials.pushnotifications" to match your app's package name.
    -->
    <category android:name="com.parse.tutorials.pushnotifications" />
  </intent-filter>
</receiver>


























轉貼請註明出處 : http://brianchen85.blogspot.tw/2014/06/android-parse.html

沒有留言:

張貼留言