I'm new to Android & also to Java....
I'm trying to get the Example of Pushy.me, it was working fine before I downloaded yesterday the last 2 Android Updates(yes I did update too late)...
New thing from Update: One UI 4.1
Now it's just doing nothing
Maybe someone knows where I'm wrong....
Here is the Code "PushReceiver"
import androidx.core.app.NotificationCompat;
import me.pushy.sdk.Pushy;
import android.content.Intent;
import android.graphics.Color;
import android.content.Context;
import android.app.PendingIntent;
import android.media.RingtoneManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
public class PushReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Attempt to extract the "title" property from the data payload, or fallback to app shortcut label
String notificationTitle = intent.getStringExtra("title") != null ? intent.getStringExtra("title") : context.getPackageManager().getApplicationLabel(context.getApplicationInfo()).toString();
// Attempt to extract the "message" property from the data payload: {"message":"Hello World!"}
String notificationText = intent.getStringExtra("message") != null ? intent.getStringExtra("message") : "Test notification";
// Prepare a notification with vibration, sound and lights
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "chanel_ID")
.setAutoCancel(true)
.setSmallIcon(R.mipmap.ic_notify)
.setContentTitle(notificationTitle)
.setContentText(notificationText)
.setLights(Color.RED, 1000, 1000)
.setVibrate(new long[]{0, 400, 250, 400})
.setColor(context.getResources().getColor(R.color.colorPrimary))
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, Main.class), PendingIntent.FLAG_UPDATE_CURRENT));
// Automatically configure a Notification Channel for devices running Android O+
Pushy.setNotificationChannel(builder, context);
// Get an instance of the NotificationManager service
NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
// Build the notification and display it
notificationManager.notify(1, builder.build());
}
}
Here is also the Run Log if i try to send Notification from WebPush:
**
D/Pushy: Received push for package im.diego.mrschprachdienst
{message=Hello World!}
** E/Pushy: Invoking push receiver via reflection failed java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at me.pushy.sdk.model.PushyCachedBroadcastReceiver.execute(PushyCachedBroadcastReceiver.java:22) at me.pushy.sdk.util.PushyBroadcastManager.sendBroadcast(PushyBroadcastManager.java:121) at me.pushy.sdk.util.PushyBroadcastManager.publishNotification(PushyBroadcastManager.java:107) at me.pushy.sdk.util.PushyMqttConnection.messageArrived(PushyMqttConnection.java:261) at me.pushy.sdk.lib.paho.internal.CommsCallback.deliverMessage(CommsCallback.java:475) at me.pushy.sdk.lib.paho.internal.CommsCallback.handleMessage(CommsCallback.java:379) at me.pushy.sdk.lib.paho.internal.CommsCallback.run(CommsCallback.java:183) at java.lang.Thread.run(Thread.java:920) Caused by: java.lang.IllegalArgumentException: im.zego.mrschluesseldienst: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags(PendingIntent.java:382) at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465) at android.app.PendingIntent.getActivity(PendingIntent.java:451) at android.app.PendingIntent.getActivity(PendingIntent.java:415) at im.zego.mrschluesseldienst.PushReceiver.onReceive(PushReceiver.java:32) ... 9 more