Android GCM, ConnectionResult=SERVICE_MISSING_PERMISSION - android

I've implemented GCM push notifications in my app according to the documentation, and it works randomly. Usually though, it spews out this error:
W/GMPM: Service connection failed: ConnectionResult{statusCode=SERVICE_MISSING_PERMISSION, resolution=PendingIntent{dee6afb: android.os.BinderProxy#c3e3718}, message=null}
After this error, it usually starts working after a while.
I haven't found any information about this, but I'd assume something is wrong with my manifest... But it's pretty much exactly the same as on the google-GCM sample.
<manifest package="fi.pauli.myapp"
xmlns:android="http://schemas.android.com/apk/res/android">
<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.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<permission
android:name="fi.pauli.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="fi.pauli.myapp.permission.C2D_MESSAGE"/>
<application
...
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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="fi.pauli.myapp"/>
</intent-filter>
</receiver>
<service
android:name="fi.pauli.myapp.PushNotificationReceiverService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<service
android:name="fi.pauli.myapp.InstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="fi.pauli.myapp.RegistrationIntentService"
android:exported="false">
</service>
</application>
</manifest>
Help, anyone? :)
Update: My RegistrationIntentService looks like this, and it does get a token each time:
public class RegistrationIntentService extends IntentService
{
public RegistrationIntentService()
{
super("RegistrationIntentService");
}
public RegistrationIntentService(String name)
{
super(name);
}
#Override
protected void onHandleIntent(Intent intent)
{
try
{
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE);
if(MainActivity.userData != null ? MainActivity.userData.getId() != 0 : false)
{
if(!token.equals(MainActivity.userData.getPush_notification_id()))
{
MainActivity.userData.setPush_notification_id(token);
MainActivity.userData.setDeviceOS(2);
DataClient.writeFile("userData.json", new Gson().toJson(MainActivity.userData), getApplicationContext());
MainActivity.updatePushIdToServer(token);
}
}
}
catch (Exception e)
{
Log.e("RegistrationService", e.getMessage());
}
}
}

I have this permission more in my manifest:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

Related

Android, FireBase Cloud Messaging, (FCM)

I am using FCM with data-messaging and can handle both foreground and background notification, but can't receive them when a phone is rebooted or app is killed (task is terminated by swiping in task manager).
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tadad.firebasetestDOUBLE">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name="com.example.tadad.firebasetestDOUBLE.AndroidApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.example.tadad.firebasetestDOUBLE.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Notification -->
<service
android:name="com.example.tadad.firebasetestDOUBLE.notification.SomeInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name="com.example.tadad.firebasetestDOUBLE.notification.SomeFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
Code:
public class SomeFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
int a = 4;
sendNotification("Smth", "Receive please!");
}
}
public class SomeInstanceIDListenerService extends FirebaseInstanceIdService {
#Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
sendRegistrationToServer(refreshedToken);
}
private void sendRegistrationToServer(String token) {
// TODO: Implement this method to send token to your app server.
}
}

Push notification is not working using parse.com android?

I have created simple push notification app using parse.com.
devices registered successfully on parse.com but when i try to send push notification through parse.com no notification have come.
AndroidMainifest.xml Code:
<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.GET_ACCOUNTS" />
<permission android:protectionLevel="signature"
android:name="com.parse.starter.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
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.parse.starter" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="" />
Reciever Code:
public class Receiver extends ParsePushBroadcastReceiver {
private Intent parseIntent;
public Receiver() {
super();
}
#Override
protected void onPushReceive(Context context, Intent intent) {
super.onPushReceive(context, intent);
if (intent == null)
return;
try {
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
parseIntent = intent;
} catch (JSONException e) {
Log.d("PushJsonException", "" + e.getMessage());
}
}
}
MainActivity Code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this);
ParseInstallation.getCurrentInstallation().saveInBackground();
}
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
// Call Methods to Update Your Stuff
}
};
#Override
protected void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, new IntentFilter("com.example.harrypotter.pushnotificationdemo"));
}
#Override
protected void onPause() {
super.onPause();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mBroadcastReceiver);
}
Application Class :
public class ParseApp extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this);
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
You have not changed the Category attribute in your Manifest file:
<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.GET_ACCOUNTS" />
<permission android:protectionLevel="signature"
android:name="com.parse.starter.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
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>
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
<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="YOUR PACKAGE NAME" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="" />
Parse.com Hosted Service is fully retiring on January 28, 2017. If you have an existing application, refer to this link and create your own push notification server. Parse release a database migration tool that lets you migrate data from your Parse app to any MongoDB database.
For More Information Check The LInk

Android Parse Push Notifications Not Working - Outdated Device

I just updated the latest Parse SDK (1.11.0) and now I'm not receiving push notifications. I am able to register successfully and can see on the parse site that that my "developer" channel has been subscribed but pushes never get sent and I get this error:
PPNS - Outdated device - The records on this installation are
outdated, the user might have uninstalled the app.
Can someone please take a look at my code and see if you notice anything incorrect?
public class LSIApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "********", "********");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("developer", 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);
}
}`
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<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:name="${applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="${applicationId}.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<permission android:protectionLevel="signature"
android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:name=".LSIApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="********" />
<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=".startup.PushBroadcastReceiver"
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>
</application>
Note: The ${applicationId} is 'com.broker.schlisimobile.dev' and/or 'com.broker.schlisimobile' depending on whether it's a production or developer build.
Here is my custom PushBroadcastReceiver class:
public class PushBroadcastReceiver extends ParsePushBroadcastReceiver {
#Override
protected void onPushOpen(Context context, Intent intent) {
if ( storyJSONExists(intent) ) {
if (!DataController.getInstance().getCurrentUser().isGuestUser() ) {
Intent i = new Intent(context, PushLoadingActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
} else {
Intent i = new Intent(context, HomeActivity.class);
i.putExtra("promptForLogin", true);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
}
} else {
Intent i = new Intent(context, HomeActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtras(i);
context.startActivity(i);
}
}
private boolean storyJSONExists(Intent intent) {
try {
String jsonString = intent.getExtras().getString("com.parse.Data");
JSONObject json = new JSONObject(jsonString);
if ( json.has("postID") ) {
return true;
}
} catch (JSONException jsonE) {
jsonE.printStackTrace();
}
return false;
}
}
In your manifest.xml comment/delete below code,
<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>
then add below code in manifest.xml
<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="your_application_id" />
</intent-filter>
</receiver>
hope it works.

Android Studio: App does not receive push notifications from parse.com

I know that this question has been asked many times but i am still unable to get push notifications from parse.com
The push Notifications are being successfully sent from parse.com but my app does not receive them.
Most people have their problem resolved using this: I can't receive push notifications in app from Parse bt that doesnt work for me.
I also tried Android - Can not Receive Push from Parse.com.
Some people suggest changing names of packages, i did that and even made a new app but didnt help.
Note: i have imported parse-1.9.1.jar and bolts-android-1.2.0.jar
Here is my MainActivity
package com.example.user.parsetest;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.parse.Parse;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this, "********", "********");
}
}
I tried adding custom PushReceiver as suggested in many answers
package com.example.user.parsetest;
import android.app.Activity;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import com.parse.ParsePushBroadcastReceiver;
public class Receiver extends ParsePushBroadcastReceiver {
#Override
protected Notification getNotification(Context context, Intent intent) {
// TODO Auto-generated method stub
return super.getNotification(context, intent);
}
#Override
public void onPushOpen(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
#Override
protected void onPushReceive(Context context, Intent intent) {
//here You can handle push before appearing into status e.g if you want to stop it.
super.onPushReceive(context, intent);
}
}
And the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<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.example.user.parsetest.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>
<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.example.user.parsetest" />
</intent-filter>
</receiver>
<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" />
<meta-data android:name="com.parse.push.notification_icon"
android:resource="#drawable/ic_launcher"/>
<!--
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="com.example.user.parsetest.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.user.parsetest.permission.C2D_MESSAGE" />
</application>
Unable to figure out the problem. pleaseeee help.
In your Application class just after the line for Parse.initialize(appkey,clientkey); just add the following line and it should work.
// Current installation object
ParseInstallation parseInstallation = ParseInstallation.getCurrentInstallation();
// Save the updated installation object
parseInstallation.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
MyLog.e(MainApplication.class.getSimpleName(), "Installation object saved "+((e!=null)?"failed":"successfully"));
}
});
Try downloading this project: https://www.dropbox.com/s/fpp22fi2o7c8vai/PushParse.zip?dl=0
It contains the 1.4.3 lib jar file. It's outdated but it's working.
I did, with a bit of tweaking, managed to update it to the latest library (1.9.2).
Watch out for errors that appear in your logcat. I got this: error setting up push notification using parse.com and android studio
If fixed by making sure my android manifest is very clean and organized. Follow the structure.
Here's my code for the updated parse library:
public class ParsePushNotification extends Application {
public ParsePushNotification() {
}
public void onCreate(){
super.onCreate();
Log.d("!!!", "This was called. Parse");
Parse.initialize(this, "paste your app id here", "paste your client id her");
// PushService.setDefaultPushCallback(this, LoginActivity.class);
// ParseInstallation.getCurrentInstallation().saveInBackground();
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);
}
}
});
}
}
That class should be used here in your manifest:
<application
android:name="com.example.app.ParsePushNotification"
Here's my receiver class:
public class Receiver extends ParsePushBroadcastReceiver {
#Override
public void onPushOpen(Context context, Intent intent) {
Intent i = new Intent(context, LoginActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
Here's my manifest:
<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" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />
<application
android:name="com.example.app.ParsePushNotification"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.NoTitle">
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="#drawable/ic_launcher" />
<activity
android:name=".LoginActivity"
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>
<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.example.app" />
</intent-filter>
</receiver>
<receiver android:name="com.example.app.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>
</application>
Good luck!

Cannot receive Parse push notifications on Android

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

Categories

Resources