taivo / parse-push-plugin

Push notification plugin for Cordova/Phonegap/ionic on Parse platform
118 stars 102 forks source link

Push not works on Android Lollipop (5) when app is closed #95

Open avilasolucoes-naora opened 7 years ago

avilasolucoes-naora commented 7 years ago

The push is received, but is not correctly manipulated, in my investigations, using log cat I see the error:

"prevent external tampering to your app's notifications, all receivers registered to handle the following actions must have their exported attributes set to false: com.parse.push.intent.RECEIVE, com.parse.push.intent.OPEN, com.parse.push.intent.DELETE".

My permissions in android manifest is correcty, according parse documentation (I change plugin.xml to get this result) and send "force-start" on push data.

`

    <receiver android:exported="false" android:name="github.taivo.parsepushplugin.ParsePushPluginReceiver">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.OPEN" />
            <action android:name="com.parse.push.intent.DELETE" />
        </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="${applicationId}" />
        </intent-filter>
    </receiver>`
adjmb commented 7 years ago

In Android 4.4.2 and Android 6, the notification is handled correctly.

Check directly in your AndroidManifest.xml the following:

<service android:name="com.parse.PushService" />
        <receiver android:exported="false" android:name="github.taivo.parsepushplugin.ParsePushPluginReceiver">
            <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="${applicationId}" />
            </intent-filter>
        </receiver>
tomazhawkjr commented 7 years ago

@adjmb, I already try with your androidManifest permissions but not work on android lollipop. In another discutions recommended add, but still not work:

<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>

The push is received (I see in logcat), but not displayed on screen.

ljunokas commented 7 years ago

no luck? anybody?

meyer-solutions commented 6 years ago

On Oreo, the ParsePushPluginReceiver has to be patched so the channel is set.

Example:


Notification.Builder builder = new Notification.Builder(context);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      String id = "ParsePush", name = pnData.optString("title");
      int importance = NotificationManager.IMPORTANCE_DEFAULT;
      String desc = pnData.optString("alert");

      NotificationChannel channel = new NotificationChannel(id, name, importance);
      channel.setDescription(desc);
      notificationManager.createNotificationChannel(channel);
      builder = new Notification.Builder(context , id);
    }