Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Is there a way to add fullScreenIntent to a notification? #1482

Open
whenmoon opened this issue Jun 13, 2020 · 6 comments
Open

Is there a way to add fullScreenIntent to a notification? #1482

whenmoon opened this issue Jun 13, 2020 · 6 comments

Comments

@whenmoon
Copy link

whenmoon commented Jun 13, 2020

Question

Hi, I'm looking to move away from custom Java modules for notifications to a React Native package. Currently I am using .setFullScreenIntent(action, true); in my notification builder, but I can't find anything similar in this package. Is there a way to do it, hacky or non-hacky?

@whenmoon
Copy link
Author

whenmoon commented Jun 13, 2020

Ok, I've almost got it and it uses the Telecom API (I think) which is great, but the notification will not dismiss on button click:

RNPushNotificationHelper.java line 273:
PendingIntent fullScreenIntent = toScheduleNotificationIntent(bundle);

RNPushNotificationHelper.java line 278:
.setFullScreenIntent(fullScreenIntent, true);

AndroidManifest.xml add singleTask:

        <activity
            android:name=".MainActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:launchMode="singleTask"

Anyone have any idea how the button presses can be hooked in to?

Using PushNotification.cancelLocalNotifications() doesn't work.

@whenmoon
Copy link
Author

whenmoon commented Jun 14, 2020

Ok I got it working!

I used this method: clearLocalNotification(id) where id must be an integer.

  PushNotification.configure({
    onNotification: (notification) => {

      //Code to print array into console
      console.log(notification);

      //Code to be executed according to the action selected by the user
      if (notification.action === "Answer") {
        console.log('%c notification.action === "ANSWER"', 'color: green;',);
        PushNotification.clearLocalNotification(1);
      }
      else if (notification.action === "Decline") {
        console.log('%c notification.action === "DECLINE"', 'color: green;',);
      }
    },
    popInitialNotification: true,
    requestPermissions: true,
  });

This basically provides the same interface that Whatsapp or HouseParty provide on an incoming call, which is what I've been looking for almost a year. I'm no Java dev so can't make a pr, but is there a plan to 'officially' support anything this?

@twelvearrays
Copy link

@whenmoon I am trying to achieve the same functionality like this for my app. Do you have any more details on how you achieved this? Thanks

@whenmoon
Copy link
Author

Hi @twelvearrays, you can either follow the steps above or use this - I forked the current dev branch and published on npm:
https://www.npmjs.com/package/react-native-push-notification-full-screen-intent

@wiserdivisor
Copy link

wiserdivisor commented Mar 8, 2021

Hi @twelvearrays, you can either follow the steps above or use this - I forked the current dev branch and published on npm:
https://www.npmjs.com/package/react-native-push-notification-full-screen-intent

This is not working for me. I get notifs but not in full screen? Any special settings for that?
@whenmoon can you also, if it's not too much trouble, upload a video demonstrating the full screen notifs?

@mateyFromTheBlock
Copy link

Checkout this PR I think it might help: #2112

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants