b8ne / react-native-pusher-push-notifications

Manage pusher interest subscriptions and notification events in Javascript.
MIT License
97 stars 85 forks source link

Notification listener is not call when application is in background. [[ Android ]] #57

Closed TrushalRank closed 3 years ago

TrushalRank commented 4 years ago

When application is in background mode and get the push notification, but when user tap on notification there are not getting notification listener method call. So, i can't handle push notification data when application is in background. This error is facing only in android platform.

Note: On foreground mode listener method works.

vborisov commented 3 years ago

I've added the missing piece in this forked repo: https://github.com/vborisov/react-native-pusher-push-notifications

In my main activity I added the following lines:

import com.b8ne.RNPusherPushNotifications.NotificationsMessagingService;

public class MainActivity extends ReactActivity {
    ...

    // Override onStart, onNewIntent:
    @Override
    protected void onStart() {
        super.onStart();
        ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
        NotificationsMessagingService.read(reactInstanceManager, this);
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
        NotificationsMessagingService.read(reactInstanceManager, this);
    }
    ...

I hope this helps until the devs here accept the pull request.

Regards

TrushalRank commented 3 years ago

Thank you @vborisov , I will try that.

TrushalRank commented 3 years ago

@vborisov , I am getting NotificationsMessagingService error in that code.

Screenshot 2020-07-25 at 10 53 59 AM

vborisov commented 3 years ago

Did you make cd android & gradlew clean after you added the code?

На сб, 25.07.2020 г., 8:24 ч. TrushalRank notifications@github.com написа:

@vborisov https://github.com/vborisov , I am getting NotificationsMessagingService error in that code.

[image: Screenshot 2020-07-25 at 10 53 59 AM] https://user-images.githubusercontent.com/49527805/88449518-2ec67c00-ce65-11ea-8831-ecb2031dc77d.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/b8ne/react-native-pusher-push-notifications/issues/57#issuecomment-663812246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZSCDJXLW6D6OCL5TRQWNLR5JUBNANCNFSM4OS6XBXA .

TrushalRank commented 3 years ago

No, i didn't.

vborisov commented 3 years ago

Well, you should in order the java files to be (re)built again and the MainActivity.java to find them (and this new notification service script).

На вт, 28.07.2020 г. в 13:15 TrushalRank notifications@github.com написа:

No, i didn't.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/b8ne/react-native-pusher-push-notifications/issues/57#issuecomment-664956607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZSCDNDXRYGYZD4NJU4G5DR52QNDANCNFSM4OS6XBXA .

-- Valentin Borisov

TrushalRank commented 3 years ago

@vborisov No, it's not gone above error.

TrushalRank commented 3 years ago

Any one can help me for solve this issue?

Ahmdrza commented 3 years ago

@vborisov I am getting the same errors as @TrushalRank was having. Can you please elaborate on what missing piece did you add in the forked repo so we can also add it in our code?

vborisov commented 3 years ago

Honestly I can't find any issues with my forked repo.

in my package.json the repo was added as below:

"react-native-pusher-push-notifications": "git+http://git@github.com/vborisov/react-native-pusher-push-notifications",

I hope this one is the only one reason why it worked on my side but not on yours. In all cases here are the differences between the forked and the official branches - https://github.com/b8ne/react-native-pusher-push-notifications/compare/master...vborisov:master

P.S. I'm not a JAVA developer and I can't give you more explanations here.

Ahmdrza commented 3 years ago

@vborisov thank you, it fixed one problem. But still, it doesn't call the callback function if the app is killed and opened via push notification.

vborisov commented 3 years ago

@Ahmdrza , I can't observe such issue. Like I said, I'm not JAVA developer, so can't help you a lot here.

Humni commented 3 years ago

@vborisov would you mind opening a PR for this? I'll happily review this for you and bundle it into a release

vborisov commented 3 years ago

Sure, I already did this. You can review it when you have a chance.

Thanks!

Humni commented 3 years ago

@vborisov awesome - PR link #55