Following Step:
1) AndroidManifest.xml file before the closing </application> tag:<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" /> <category android:name="app-package-name" /> your app package name </intent-filter></receiver><receiver android:name="com.parse.ParsePushBroadcastReceiver"android:exported="false"> <intent-filter> <action android:name="com.parse.push.intent.RECEIVE" /> <action android:name="com.parse.push.intent.DELETE" /> <action android:name="com.parse.push.intent.OPEN" /> </intent-filter></receiver>2) set permission in AndroidManifest.xml file, before the <application> tag:<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" /><permission android:protectionLevel="signature" android:name="app-package-name.permission.C2D_MESSAGE" />your app package name<uses-permission android:name="app-package-name.permission.C2D_MESSAGE" /> your app package name3) AndroidManifest.xml file before the closing </application> tag:
<meta-data
android:name="com.ad4screen.senderid"
android:value="GCM-SENDER-ID" />your app google gcm id
<!-- <meta-data -->
<!-- android:name="com.ad4screen.notifications.accent_color" -->
<!-- android:value="#ff0000ff" /> -->
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/ic_launcher_push" />
4) Create class and extends Application (Create Application class) and write below code in onCreate() method:
Parse.enableLocalDatastore(this);
Parse.initialize(this, "Application-ID", "Client-Key");
// get on Parse Registration in web
// https://parse.com/tutorials/android-push-notifications
ParsePush.subscribeInBackground("", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
PushService.setDefaultPushCallback(this, SunAct_Home.class); back Activity name
// https://parse.com/tutorials/android-push-notifications
5) Put library(libs) folder of Parse SDk sample to your project:// https://parse.com/tutorials/android-push-notifications
Good I help ful this code and successfully got the push from server thanks buddy...!!!!
ReplyDeleteMost welcome dear..
Delete