I want to send push Notification using Parse API and GCM. I have done successfully configuration on server and test via sending push notification form Parse terminal and receive at android device.
But when i'm sending push programmatically then got an Exception: "unauthorized: master key is required".
I using following code:
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("channels", "testing");
// Notification for Android users
query.whereEqualTo("deviceType", "android");
ParsePush androidPush = new ParsePush();
androidPush.setMessage("Your suitcase has been filled with tiny robots!");
androidPush.setQuery(query);
androidPush.sendInBackground(new SendCallback() {
#Override
public void done(ParseException e) {
if ( e == null ) {
Log.d("GARG","Parse Notification Done. : ");
} else {
Log.d("GARG","Notification failed.: "+e.getMessage());
e.printStackTrace();
}
}
});
android manifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo">
<permission
android:name="com.demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.demo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<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:name="com.demo.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.demo.permission.C2D_MESSAGE" />
<application
android:name=".AppInitializer"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true">
<service android:name="com.parse.PushService" />
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="#drawable/ic_cast_light" />
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:211671060483" />
<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" />
<meta-data
android:name="com.parse.X-Parse-Master-Key"
android:value="#string/parse_master_key" />
<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="com.demo" />
</intent-filter>
</receiver>
</application>
Initialize Parse SDK in android
public class AppInitializer extends Application {
public static JSONObject errorDataProvider;
#Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(getApplicationContext());
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId(Utility.ApplicationId)
.clientKey(Utility.ClientKey)
.server(Utility.Server_URL)
.build()
);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground(Utility.PARSE_CHANNEL, new SaveCallback() {
#Override
public void done(ParseException e) {
Log.e("GARG", "Successfully subscribed to Parse!");
}
});
}
}
UPDATED ANSWER
Hi, i investigate it a bit and found that currently the only to send Push is by using the masterKey and that's exactly the reason why you are getting this error
In order to send push with master key the best approach will be to create a cloud code function and trigger this function from the client side.
so you need to do the following:
Inside your cloud code main.js file create a new function
Parse.Cloud.afterSave("SendPush", function(request) {
var query = new Parse.Query(Parse.Installation);
query.exists("deviceToken");
// here you can add other conditions e.g. to send a push to sepcific users or channel etc.
var payload = {
alert: "YOUR_MESSAGE"
// you can add other stuff here...
};
Parse.Push.send({
data: payload,
where: query
}, {
useMasterKey: true
})
.then(function() {
response.success("Push Sent!");
}, function(error) {
response.error("Error while trying to send push " + error.message);
});
});
After you created the cloud code function restart your server
Trigger this cloud code function from your android app in the following way:
HashMap<String,String> map = new HashMap<String, String>();
map.put("PARAM1KEY","PARAM1VALUE");
// here you can send parameters to your cloud code functions
// such parameters can be the channel name, array of users to send a push to and more...
ParseCloud.callFunctionInBackground("SendPush",map, new FunctionCallback<Object>() {
#Override
public void done(Object object, ParseException e) {
// handle callback
}
});
This will trigger a call to the cloud code function that you created above and inside the cloud code the useMasterKey is true so it should work.
update: spelling
useMasterKey: true
that will enable parse server to use master key to push notification from client side.
Related
I've configured Push notifications in Android for an app following all the instructions in:
https://github.com/ParsePlatform/Parse-Server/wiki/Push-Configuring-Clients
https://parseplatform.github.io/docs/android/guide/#push-notifications
But no matter what I do, the mobile phone I'm using can't seem to get any push notifications at all.
The same app is configured to receive the notifications on iOS and works perfectly.
These are the relevant bits in the Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxy.xxy">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission
android:name="com.xxy.xxy.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.xxy.xxy.permission.C2D_MESSAGE" />
<application
android:name="com.xxy.xxy.MiXXYApplication"
android:allowBackup="true"
android:icon="#drawable/logoapp"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<service android:name="com.parse.PushService" />
<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="com.xxy.xxy" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.push.gcm_sender_id"
android:value="id:123456789012" />
</application>
This is the Application class (with the AppID and Client Key replaced with the current value given by Back4App):
public class MiXXYApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId("back4App_AppID")
.clientKey("back4App_ClientKey")
.server("https://parseapi.back4app.com/")
.build()
);
}
}
These are the methods I call to register the installation (I can't do it on the Application class because I need the userId, after login)
public void enablePush(final String userId) {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("GCMSenderId", "123456789012");
installation.put("userId", userId);
installation.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.i("push", "ok");
subscribe("");
subscribe(userId);
} else {
Log.i("push", "nok");
e.printStackTrace();
}
}
});
}
public void subscribe(String channel){
ParsePush.subscribeInBackground(channel, new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.i("Push", "subscribed");
} else {
Log.i("push", "nok");
e.printStackTrace();
}
}
});
}
This is the installation registry on the Parse DB:
ObjectID: l1tkO3YM2r
GCMSenderID: 123456789012
deviceToken: APA91bHeKnj...
localeIdentifier: en-US
badge: (undefined)
parseVersion: 1.13.1
ACL: Public Read + Write
appIdentifier: com.xxy.xxy
appName: appName
deviceType: android
channels: ["","CyTPw5xc4r"]
pushType: gcm
installationId: 8cf9c606-5a0e...
userId: CyTPw5xc4r
In the google developer console, the project number is 123456789012, I've created an API key and added the API key + the project number in the Back4App dashboard's Android Push Notification Settings.
The logcat in verbose mode is showing the following:
09-21 09:29:19.863 10721-10721/com.xxy.xxy V/com.parse.ManifestInfo: Using gcm for push.
09-21 09:29:19.884 10721-10885/com.xxy.xxy V/com.parse.CachedCurrentInstallationController: Successfully deserialized Installation object
09-21 09:29:19.899 10721-10886/com.xxy.xxy V/com.parse.GcmRegistrar: Sending GCM registration intent
09-21 09:29:29.782 10721-11340/com.xxy.xxy V/com.parse.GcmRegistrar: Received deviceToken <APA91bHeKnj...> from GCM.
For what I can tell, everything's good to go, but I'm not getting any notification in my phone.
Is there anything wrong with my setup?
Thanks!
Solved it!
The thing is that, instead of getting the Api key the way all the guides say, you should get it from https://developers.google.com/mobile/add.
It generated another API key and activated the service, and then, it worked.
I am developing simple android app and very new to parse. I followed parse documentation in adding back-end functionalities. Parse CORE was an easy part but I can’t send push notifications from android device. But push-notifications are received when sent from parse dashboard.
My Manifest file is as below:
<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" />
<uses-permission android:name="com.google.android.c2dm.permission.SEND" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="loaniistar.loaniistar.permission.C2D_MESSAGE" />
<uses-permission android:name="loaniistar.loaniistar.permission.C2D_MESSAGE" />
<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="loaniistar.loaniistar" />
</intent-filter>
</receiver>
Application Class:
public class MApplication extends Application {
String applicationiId = "5npdddECsGdDk49OttttuHq6iZdZpddI0cHDsz";
String clientKey = "SjF1BWamssstycthSjf2dddduhcuwW2VccccCCuFlE";
public UserAccounts userAccount = null;
#Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
ParseCrashReporting.enable(this);
Parse.initialize(this, applicationiId, clientKey);
PushService.startServiceIfRequired(this);
}
}
Subscribing for channel in an activity class:
ParsePush.subscribeInBackground("manager", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
}
else
{
btnLoginEnable();
}
}
});
Sending Push Notification in another activity class:
// Sending Push
ParsePush push = new ParsePush();
push.setChannel("manager");
push.setMessage(m.getMessage().substring(0, (int) m.getMessage().length() / 3));
//push.sendInBackground();
push.sendInBackground(new SendCallback() {
#Override
public void done(ParseException e) {
if(e == null)
{
Toast.makeText(getActivity(), "Notification sent", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getActivity(), "Notification Not sent", Toast.LENGTH_SHORT).show();
}
}
});
Row is added in “Installation” class and GCMSenderId is empty!! Is this the issue?
Please help me out why I can’t receive notifications when sent from my android device?
Libs used:
Bolts-android-1.1.4.jar
Parse-1.8.2.jar
ParseCrashReporting-1.8.2.jar
If you have just created the App in Parse and integrated in your App, It generally not works immediately Same thing happened to me. I was not getting the data, but after some time I got the requests when I saw the Parse Dashboard
It will take Approx 20 mins. You can try to see the Parse Analytics.(if you have implemented it) if Parse shows Requests in your Analytics Dashboard then It will work completely fine
I need help, because I am working with Parse Push Notification Android but my application just receives notifications in emulator but not receives in real devices.
In my analytics appears register.
This is my permission and BroadcastReceiver:
<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="org.example.promociones.permission.C2D_MESSAGE" />
<uses-permission android:name="org.example.promociones.permission.C2D_MESSAGE" />
<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.example.promociones.Receiver"
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>
And my code of registration:
Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Parse.initialize(this, "SomeValue", "SomeValue");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("pruebas", new SaveCallback() {
#Override
public void done(com.parse.ParseException e) {
// TODO Auto-generated method stub
if(e!=null)
{
Log.d("com.parse.push", "La subscripcion al canal fue exitosa");
}
else
{
Log.e("com.parse.push", "Fallo la subscripcion push");
}
}
});
}
use the following instead:
// inform the Parse Cloud that it is ready for notifications
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
} else {
e.printStackTrace();
}
}
});
i had the same problem and it was because i didn't check package name
<permission
android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
I am trying to implement parse push notification in my android project. to understand, I am giving some project flow.
saving user details on personal server using php API
server send me some push notification.
I get notification but I am not getting any action, data in that push notification in my custom broadcast receiver.
Here is my Android Manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<permission
android:name="com.mypackage.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mypackage.myapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name="com.mypackage.myappe.MyApplication"
android:allowBackup="true"
android:icon="#drawable/dwtlogo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<service android:name="com.parse.PushService" />
<receiver
android:name="com.mypackage.myapp.MyCustomReceiver"
android:exported="false" android:enabled="true">
<intent-filter>
<action android:name="com.mypackage.myapp.MESSAGE" />
</intent-filter>
</receiver>
<category android:name="com.mypackage.myapp" />
</application>
Here is MyApplication.java
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "xxxxxxxx", "xxxxxxxxxx");
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
PushService.setDefaultPushCallback(getApplicationContext(), DashBoardActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseUser.enableAutomaticUser();
//String deviceToken= (String) installation.get("deviceToken");
//Toast.makeText(this, "Device token="+deviceToken, Toast.LENGTH_LONG).show();
PushService.subscribe(this, "Wake_up", DashBoardActivity.class);
}
And here is my custom receiver in which i am trying to get action and data which server sending me but my custom receiver not getting called.
String action = intent.getAction();
Log.d(TAG, "got action " + action );
if (action.equals("com.mypackage.myapp.MESSAGE"))
{
String channel = intent.getExtras().getString("com.parse.Channel");
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
Log.d(TAG, "got action " + action + " on channel " + channel + " with:");
Iterator itr = json.keys();
while (itr.hasNext()) {
String key = (String) itr.next();
//if (key.equals("customdata"))
//{
Intent pupInt = new Intent(context, ShowPopup.class);
pupInt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
context.getApplicationContext().startActivity(pupInt);
//}
Log.d(TAG, "..." + key + " => " + json.getString(key));
}
}
}
} catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
Even no any log getting printed. Here is php server code which sending me push notification.
$data = array(
'channel' => $chnl,
'action' => 'com.mypackage.myapp.MESSAGE',
'data' => array(
'alert' => $message,
'sound' => 'push.caf',
'photourl' => $imageurl,
)
);
But i don't understand where i need to get this data so i can show image after receiving push notification.
Please give me any hint or reference.
Adding receiver for GcmBroadcastReceiver should help. As given out in the tutorial here.
Other reference.
<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>
I have one question about C2DM, I registered yesterday and I got email that my mail and app are approved. From app I get registration_id, I have broadcast_receiver like
#Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
android.util.Log.d("REG_1","onReceive");
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
final String registrationId = intent
.getStringExtra("registration_id");
String error = intent.getStringExtra("error");
android.util.Log.d("REG_1",registrationId);
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(context);
String token = prefs.getString("token", null);
String userId;
try {
userId = RestClient.getUserIdByToken(token).getString(
"user_id");
Intent i = new Intent(context, RegService.class);
i.putExtra("c2dm_registration_id",registrationId);
i.putExtra("token", token);
i.putExtra("user_id", userId);
i.putExtra("device_id", "bla");
i.setAction(android.content.Intent.ACTION_VIEW);
context.startService(i);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
saveRegistrationId(context, registrationId);
}
and I enter in this function during registration and I send messages from command line like
curl https://www.google.com/accounts/ClientLogin -d Email=MYGOOGLEACCOUNT#gmail.com -d "Passwd=MY_PASSWORD" -d accountType=GOOGLE -d source=Google-cURL-Example -d service=ac2dm
and
curl --header "Authorization: GoogleLogin auth=DQAAAMMAAAC58D4X-5zjQFdYuGz7D9DhnuN4OUiz_gCtOJRSNwNLN0-wxveAEVL985hNKJXyQ_7U4sTfsUGh_3OXMLKpB5PNN1eaI4AfT19LaJ1vGJCZ_sSE0NDqGsC0mZVdMsYbE2Sz1r1WE_p5WNokfGMRdmxIHl0QCWb43lTD3iCvr51ujmnHnvpn2mDLWr6j9DtyDxADRw1to2iGgpJNelXmIA8tOzjyqF3szN-N2IYnihJ8H2t3G5wotOWy1EahB43Lv2NPdlV-A4yVSbdsYGM_AVdd" "https://android.apis.google.com/c2dm/send" -d registration_id=APA91bHhbsPedDVnYCaSJQMhWjfjK3W9jOaMgVITUHqw97w4fF_8fermSG22CzFvpPuTyRKnJFyJ_iwfgJEJ4uidURxuHZCCBuPtGAsv6NeVipmOd53Fkru_A3NW3cpIMo9gvuVxIB0QqxOvl1SmVfqRzD4qQfSNaw -d "data.test_result=This data will be send to your application as payload" -d collapse_key=2
id=0:1322216144957968%b3c4048a00000032
but it never enter in onHandle function of broadcatreceiver.
<receiver
android:name="com.surveyce.android.c2dm.C2DMRegistrationReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter >
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.surveyce.android" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter >
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.surveyce.android" />
</intent-filter>
</receiver>
...
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!--<uses-permission android:name="android.permission.WAKE_LOCK" />-->
<uses-permission android:name="com.surveyce.android.permission.C2D_MESSAGE" />
<permission
android:name="com.surveyce.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Did anybody have similar strange problems that get registrationId and send messages but do not receive message on phone ? What can be problem, maybe because I registered yesterday ( but how than I get rigistrationId and auth for that account) ? Package names and gmail are account are 100% ok.
Add a service tag [write your receiver name in below service tag which is sub class of C2DMBaseReceiver]
<service android:name=".C2DMReceiver" />
Use C2DMBroadcastReceiver Instead of C2DMRegistrationReceiver
<receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
You can refer following Link for proper implementation of C2DM Google C2DM service