Parse Notification not working in Android - android

Parse notification not receiving in android app from Parse Server.
In Below link it shown notification is not sent with Push sent 0 on parse serve
https://www.parse.com/apps/bluejay-test/push_notifications/mmBUWvc8US
Also in Parse Account Client push enabled is Yes.
I am sending the push notification from parse cloud server its not receiving in android APP but receive in ios APP .Its sometime come in android mobile.
Please suggest me what is the issue?
In Login User Time, I am using this code
ParseInstallation.getCurrentInstallation().put("uuid",user.getUuid());
ParseInstallation.getCurrentInstallation().put("email",parseUser.getEmail());
ParseInstallation.getCurrentInstallation().put("uuid",user.getUuid());
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
#Override
public void done(ParseException arg0) {
}});
and also also followed all the trouble shooting steps and added the configuration in AndroidManifest.xml
<permission
android:name="com.redblink.bluejay.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.redblink.bluejay.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver
android:name="com.redblink.bluejay.CustomParsePushBroadcastReceiver"
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>
<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="com.redblink.bluejay" />
</intent-filter>
</receiver>
I have added the CustomParsePushBroadcastReceiver for receiving the notification
public class CustomParsePushBroadcastReceiver extends ParsePushBroadcastReceiver {
private String TAG ="CustomParsePushBroadcastReceiver" ;
BlueJayApplication application;
#Override
public void onReceive(Context context, Intent intent) {
BlueJayApplication application = (BlueJayApplication) context.getApplicationContext();
Bundle e = intent.getExtras();
for (String key : e.keySet()) {
BluejayDebug.Log(TAG, "Extra: " + key);
BluejayDebug.Log(TAG, "" + e.getString(key));
}
BluejayNotificationManager.Init(context);
BluejayNotificationManager.getInstance().sendGenericNotification("BlueJay", "New bluejay event");
}
public void setApplication(){
}
}

Modify this
<receiver
android:name="com.redblink.bluejay.CustomParsePushBroadcastReceiver"
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>
To this
<receiver android:name="com.redlink.bluejay.CustomParsePushBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>

The function you should be overriding is onPushReceive() not onReceive(). Change the function and that will fix the issue.
The documentation explains that.
https://parse.com/docs/android/api/com/parse/ParsePushBroadcastReceiver.html

Related

Parse.com could not push notification to multiple devices android

My application used Parse to push notification to multiple devices. But only one devices can receive that notification. I don't know why? Please help me. Here're some code :
AppController:
// Add your initialization code here
Parse.initialize(this, getString(R.string.parse_app_id), getString(R.string.parse_client_key));
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("RadaBikeSp", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d("Success", "successfully subscribed to the broadcast channel.");
} else {
Log.e("Fail", "failed to subscribe for push", e);
}
}
});
in Manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<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" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<permission
android:name="thsoft.com.sosme.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="thsoft.com.sosme.permission.C2D_MESSAGE" />
<application
android:name=".services.AppController"
android:allowBackup="true"
android:fullBackupContent="true"
android:hardwareAccelerated="true"
android:icon="#drawable/iconapp"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="#string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="#string/parse_client_key" />
<service android:name="com.parse.PushService" />
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<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>
<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="thsoft.com.sosme" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="#drawable/iconapp" />
Thank in advance!
Your app needs to access to internet for using parse push notification.
please add this permission to your manifest :
<uses-permission android:name="android.permission.INTERNET" />
You have to exclude the GCM registration key from your fullBackupContent like here: https://github.com/googlesamples/android-AutoBackupForApps

Parse Push Notification working on Emulator but not working on Android device

I have created an chat application in android. It is working fine . Also notifications are working on emulators. But when I try it on device there seems no notification receiving. I followed tutorials of parse regarding Android for message and notification but still on device there is no notification coming. Guide me regarding the same.
My manifest file has following permissions:
package="com.gestureMsg.messenger"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.gestureMsg.messenger.permission.C2D_MESSAGE" />
<uses-permission android:name="com.gestureMsg.messenger.permission.C2D_MESSAGE" />
<application
android:name="packgest.MessengerApplication"
android:allowBackup="true"
android:icon="#drawable/msg"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:1076345567071" />;
<meta-data android:name="com.parse.push.notification_icon" android:resource="#drawable/msg"/>
<activity android:name="packgest.MainActivity" android:screenOrientation="portrait">
<intent-filter >
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="packgest.CurrentUserActivity" android:screenOrientation="portrait"></activity>
<activity android:name="packgest.NewUserActivity" android:screenOrientation="portrait"></activity>
<activity android:name="packgest.ShowContactsWithApp" android:screenOrientation="portrait"></activity>
<activity android:name="packgest.ViewProfileActivity" android:screenOrientation="portrait"></activity>
<activity android:name="packgest.RefreshActivity" android:screenOrientation="portrait"></activity>
<activity android:name="packgest.AfterNotificationActivity" android:screenOrientation="portrait"></activity>
<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.ParsePushBroadcastReceiver" android:exported="false"> -->
<receiver android:name="packgest.Reciever" 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>
<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="com.gestureMsg.messenger" />
</intent-filter>
</receiver>
</application>
My push code is :
// Notification for Android users
ParsePush androidPush = new ParsePush();
androidPush.setMessage(currentUser.getUsername());
androidPush.setQuery(query);
androidPush.sendInBackground();`
My application class code :
public class MessengerApplication extends Application {
private final static String APP_ID="xxx";
private final static String CLIENT_KEY ="xxx";
#Override
public void onCreate() {
// TODO Auto-generated method stub
Parse.enableLocalDatastore(getApplicationContext());
Parse.initialize(getApplicationContext(),APP_ID,CLIENT_KEY);
ParseInstallation.getCurrentInstallation().saveInBackground();
// the channel "" is called the "broadcast" channel and is used for broadly applicable messages
ParsePush.subscribeInBackground("", new SaveCallback()
{
#Override
public void done(ParseException e)
{
if (e == null)
{
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
System.out.println("successfully subscribed to the broadcast channel.");
}
else
{
Log.e("com.parse.push", "failed to subscribe for push", e);
System.out.println("failed to subscribe for push."+e.getMessage());
}
}
});
PushService.setDefaultPushCallback(this, CurrentUserActivity.class);
super.onCreate();
}
}

Parse push notification send not working

I cannot send pushnotification from my application via Parse. I checked every settings:
Manifest has been set correctly (permissions, package names)
Parse has been initialized (with right keys), and localdatastore enabled
All device use the same pushnotification channel, and subscribed to it
On the Parse admin page, "Client push enabled" checked
After all of this, i want to send a pushnotification, but i cannot do this. I started to debug this issue.
First of all, i checked that the push notification had been sent or not.
ParsePush push = new ParsePush();
push.setChannel(channel);
push.setMessage(message);
push.sendInBackground(new SendCallback() {
#Override
public void done(ParseException e) {
Log.d("SEND PUSH", (e == null) ? "SUCCESSFULL": "FAILED");
}
});
But this method returns with "SUCCESSFULL". So it has to be good. But on the Parse admin page and on the devices it is not showing.
I was curious, that i can receive push notifications, so i sent a pushnotification to my channel, from the parse admin page. And that worked.
So i think, the problem is in the sending method or in the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="conversation.laszlomagyar.hu" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- parse permissions -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="conversation.laszlomagyar.hu.permission.C2D_MESSAGE" />
<permission android:protectionLevel="signature"
android:name="conversation.laszlomagyar.hu.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name=".ApplicationObject">
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data android:name="com.parse.push.notification_icon"
android:resource="#mipmap/ic_launcher"/>
<activity
android:name=".ui.StarterActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.Activity"
android:label="#string/rooms"
android:screenOrientation="portrait"/>
<activity android:name=".ui.Activitytwo"
android:label="#string/app_name"
android:screenOrientation="portrait"/>
<activity android:name=".ui.Activitythree"
android:label="#string/create_room"
android:screenOrientation="portrait" />
<!-- parse stuffs -->
<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.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>
<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="conversation.laszlomagyar.hu" />
</intent-filter>
</receiver>
</application>

Cannot receive push notification from parse.com

I have implemented what parse.com had in their tutorial and when I send a push from parse dashboard it says Succeeded but the number of pushes sent is 0. However whenever I want to send the push it says recepient 1 which means it recognizes my device. I did what it says in this link but it doesnt work:
I can't receive push notifications in app from Parse
I'm very confused why I'm not receiving any notification here is my Application class code:
Parse.initialize(this, "xxxxx", "xxxxx");
ParseInstallation.getCurrentInstallation().saveInBackground();
Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
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);
}
}
});
here is my manifest permission:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission android:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.permission.C2D_MESSAGE" />
and here is the rest of manifest related to parse push:
<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="com.myapp.main" />
</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>
<!-- replace #drawable/push_icon with your push icon identifier -->
<meta-data android:name="com.parse.push.notification_icon" android:resource="#drawable/applogo"/>
EDIT: Here is the log:
02-25 13:52:53.681 4636-4653/com.myapp.main E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<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="com.myapp.main" />
</intent-filter>
</receiver>
02-25 13:57:13.004 5598-5598/com.myapp.main E/com.parse.PushService﹕ Tried to use push, but this app is not configured for push due to: Push is not configured for this app because the app manifest is missing required declarations. Please add the following declarations to your app manifest to support either GCM or PPNS for push (or both). To enable GCM support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<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="com.myapp.main" />
</intent-filter>
</receiver>
To enable PPNS support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<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>
02-25 14:12:25.534 10046-10046/com.myapp.main E/com.parse.push﹕ successfully subscribed to the broadcast channel.
android:name="com.myapp.main.permission.permission.C2D_MESSAGE"
Can you change it to have only one "permission" in the name?
I changed my manifest to this:
<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.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>
<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.starter" to match your app's package name.
-->
<category android:name="com.vitrin.main" />
</intent-filter>
</receiver>
I still get that error + :
02-25 15:44:33.042 32710-32710/com.myapp.main E/com.parse.PushService﹕ PushService somehow started even though this device doesn't support push.
02-25 15:44:33.042 32710-32710/com.myapp.main E/com.parse.PushService﹕ Started push service even though no push service is enabled: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.myapp.main cmp=com.myapp.main/com.parse.PushService (has extras) }
02-25 15:45:10.508 32710-32710/com.myapp.main E/com.parse.PushService﹕ Started push service even though no push service is enabled: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.myapp.main cmp=com.myapp.main/com.parse.PushService (has extras) }
but for some reason it is working!!

BroadcastReceiver works on emulator not on device

I am using Parse to send notifications from device to device. I've set up a broadcast receiver to generate a custom notification when it receives intent from a notification coming in from Parse. The problem is that the broadcast receiver on the emulator works just fine but on the device it just does not receive the intent.
AndroidManifest
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<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.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="org.example.app.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
<activity
android:name="org.example.app.MainActivity"
android:label="#string/app_name"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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.starter" to match your app's package name.
-->
<category android:name="org.example.app" />
</intent-filter>
</receiver>
<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="org.example.app.Receiver"
android:priority="999999999"
android:exported="true"
android:enabled="true">
<intent-filter android:priority="999999999">
<action android:name="org.example.app.A_CUSTOM_INTENT"/>
</intent-filter>
</receiver>
</application>
An this is the onClick that calls for a Parse notification
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "this is shown" , Toast.LENGTH_LONG).show();
try {
ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
JSONObject data = new JSONObject("{\"action\": \"org.example.app.A_CUSTOM_INTENT\"}");
ParsePush androidPush = new ParsePush();
androidPush.setData(data);
androidPush.setExpirationTimeInterval(120);
androidPush.setQuery(query);
androidPush.sendInBackground();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
As I've said, this works on an emulator just fine and the device does receive notifications from the Parse service but does not respond to intent. Thank you for your help.
Looks like you have an error here :
<permission android:protectionLevel="signature"
android:name="org.example.app.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />
I'm assuming the correct value is org.example.app (based on the rest of the manifest), so it should be :
<permission android:protectionLevel="signature"
android:name="org.example.app.permission.C2D_MESSAGE" />
<uses-permission android:name="org.example.app.permission.C2D_MESSAGE" />
The reason it works on the emulator and not on the device could be that the device has an older Android version. This error affects only 2.x Android devices.

Categories

Resources