pusher / push-notifications-android

Android SDK for Pusher Beams
https://www.pusher.com/beams
MIT License
21 stars 22 forks source link

Push Notifications force opens killed app when received. #44

Closed thejbix closed 6 years ago

thejbix commented 6 years ago

The issue I'm having is if I receive a notification after my app is killed, then that notification opens the app instantly without any user interaction.

Testing on android version 8.1.0 - SDK Version 27

Can't find any options that would allow me to change that behavior.

luismfonseca commented 6 years ago

Could you tell us what SDK version are you using? Is it the latest 0.10.0?

What's the notification payload you're sending? If you could also create a minimum reproducible case, that would be great.

thejbix commented 6 years ago

I'm using the latest SDK version - 0.10.0

Payload fcm: { notification: { title: "Some Title", body: "Some Body" }, data: { "some_field": "some_field_data" } }

Edit: Also the server is configured to support ios pusher push notifications as well.

apns: { aps: { alert: { title: "Some Title", body: "Some Body" }, "mutable-content": 1, }, data: { "some_field": "some_fielddata } },

thejbix commented 6 years ago

Minimum reproducible case. I have followed the basic instructions from https://docs.pusher.com/push-notifications

build.gradle dependencies { implementation 'com.google.firebase:firebase-core:15.0.0' implementation 'com.google.firebase:firebase-messaging:15.0.0' implementation 'com.pusher:push-notifications-android:0.10.0' }

apply plugin: 'com.google.gms.google-services'


Pusher Implementation

public class PushService extends MessagingService {

public PushService() {}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

//I get this message when receiving a notification while app in foreground Log.d("NotificationsService", "Got a remote message 🎉"); }

public static void startPushService(@NotNull Profile profile, @NotNull Context context) {

    PushNotifications.start(context, "Pusher Key");

    PushNotifications.subscribe("Some Interest");

}

public static void stopPushService() {

    PushNotifications.unsubscribeAll();

}

}

luismfonseca commented 6 years ago

That example is not really valid, e.g. Some Interest is not a valid interest name.

This SDK has a sample_kotlin project and I've run that with your SDK and Android version + the payload in your example and I can't replicate the issue.

Try running the sample_kotlin example yourself and let me know what needs to change in order for us to reproduce the issue. Thanks.

thejbix commented 6 years ago

I found the reason.

I have a class that extends Application. In that class's onCreate method, I called an Intent to go to another activity. When I take out that intent, the push notification does not force open the app.

luismfonseca commented 6 years ago

Good to hear!

Let me know if you come across any other difficulties. Closing this issue.