1

I have downloaded a Xamarin.Android push notification sample project from Parse.com, and it works when application is in foreground or minimized. If I kill application from Recent Applications screen the application will not show the future notifications.

My manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.parse.parsexamarinpushsample" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<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.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.parse.parsexamarinpushsample.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.parsexamarinpushsample.permission.C2D_MESSAGE" />
<application android:name="parsexamarinpushsample.ParseApplication" android:label="ParseXamarinPushSample" android:icon="@drawable/Icon" android:theme="@android:style/Theme.Light">
    <receiver android:name="parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <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" />        
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.parse.parsexamarinpushsample" />
        </intent-filter>
    </receiver>
    <service android:name="parse.ParsePushService" />
</application>

My Code:

public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        ParseClient.Initialize("appid", "clientid");
        ParsePush.ParsePushNotificationReceived += ParsePush.DefaultParsePushNotificationReceivedHandler;
        ParsePush.ParsePushNotificationReceived += ParsePushOnParsePushNotificationReceived;

        ParseInstallation installation = ParseInstallation.CurrentInstallation;

        installation.SaveAsync();

        return StartCommandResult.Sticky;
    }

After sending notification i noticed on Parse Dashboard that notification is marked as "Successful" so I have a reason to believe that my phone is receiving the notification but there is no application that can handle it.

Do i need some intent action for broadcast receiver or something is wrong with my manifest?

Thanks in advance

Xzil0
  • 173
  • 1
  • 1
  • 8
  • the reason is, if you are killing your app, you are also killing services and broadcast receivers which are connected to this app. because of that your app is not able to receive notifications. there are ways to restart these services but they are rather complex – Rich Jan 26 '16 at 09:27
  • 1
    I kill Viber, Instagram and Facebook Messenger the same way and i still get notifications from those services. Do you know how to implement that behavior with Parse API ? – Xzil0 Jan 26 '16 at 09:30
  • as i said, there are ways to restart the services automatically when they get killed. you have to find a way to do this (e.g. http://stackoverflow.com/questions/21550204/how-to-automatically-restart-a-service-even-if-user-force-close-it) – Rich Jan 26 '16 at 09:32

1 Answers1

0

remove delete permission from menifiest file. change you permission like this

<service android:name="com.parse.PushService" /> 
<service android:name="com.performtec.notification.PushHandler" />
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
 <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
 <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
  <category android:name="com.PackageName.packageName" /> 
Binesh Kumar
  • 2,763
  • 1
  • 16
  • 23