react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

display notification when application state is "dead"

Open Crash-- opened this issue 9 years ago • 10 comments

Hi guys,

I'm moving from React Native Push Notification to this lib because RNPN doesn't work well with React-Native-Navigation...

I can receive notification if my application is in "dead" state. The icon is added to the system top bar and I got a vibration, that's all. How to display it with its content as the other apps do?

Here is an exemple of what we can do (without no code modification / addition) with RNPN. screenshot_2016-12-27-15-26-09

Is it something we can do with Wix RN-Notifications? Or do we need to customize Notification Classes etc?

Crash-- avatar Dec 27 '16 14:12 Crash--

Same issue in here.

kristikristo avatar Dec 28 '16 15:12 kristikristo

It seems that this type of notification is called Heads-up notifications on Android (https://developer.android.com/guide/topics/ui/notifiers/notifications.html#Heads-up) but the default behavior is just to have an icon :/

We can definitely set a higher priority and so on, but not sure how we can display this banner on the home screen

Crash-- avatar Dec 28 '16 15:12 Crash--

Is this still relevant?

d4vidi avatar Jan 02 '17 16:01 d4vidi

Yes... Can we have this as the default behavior?

I tried to override PushNotification but I've an issue since the wiki said we have to write something like :

public class MyPushNotification extends PushNotification {

    public MyPushNotification(Context context, Bundle bundle, AppLifecycleFacade appLifecycleFacade) {
        super(context, bundle, appLifecycleFacade);
    }

I tried, but the super constructor wants 5 arguments... How can I solve this issue? capture d ecran 2017-01-02 a 17 09 02

Crash-- avatar Jan 02 '17 16:01 Crash--

Just aded :

   super(context, bundle, appLifecycleFacade, new AppLaunchHelper(), new JsIOHelper());

Seems to work as expected. Can you update the wiki?

Also, if we can have some leads to have the behavior described in the first post, it'll be very helpful since I added an Hight priority but I still have no banner with my Push :(

Crash-- avatar Jan 02 '17 16:01 Crash--

Sure, thank you!

d4vidi avatar Feb 18 '17 13:02 d4vidi

Any updates on this?

kaloncheung124 avatar Nov 15 '17 19:11 kaloncheung124

I was able to make a heads-up notification appear by adding

builder.setPriority(PRIORITY_HIGH);

to the class:

public class PushNotificationBanner extends PushNotification {

    public PushNotificationBanner(Context context, Bundle bundle, AppLifecycleFacade appLifecycleFacade, AppLaunchHelper appLaunchHelper, JsIOHelper jsIoHelper) {
        super(context, bundle, appLifecycleFacade, appLaunchHelper, jsIoHelper);
    }

    @Override
    protected Notification.Builder getNotificationBuilder(PendingIntent intent) {
        final Resources resources = mContext.getResources();

        // First, get a builder initialized with defaults from the core class.
        final Notification.Builder builder = super.getNotificationBuilder(intent);

        // Set our custom overrides --

        // Enable 'extended' layout (extends on down-stroke gesture):
        final Notification.BigTextStyle extendedNotificationStyle =
                new Notification.BigTextStyle()
                        .bigText(mNotificationProps.getBody()); // "4:15 - 5:15 PM\nBig Conference Room"
        builder.setStyle(extendedNotificationStyle);

        // Set custom-action icon.
        builder.setSmallIcon(R.drawable.ic_launcher);

        // Set high priority for notification
        builder.setPriority(PRIORITY_HIGH);

        return builder;
    }
}

kaloncheung124 avatar Nov 15 '17 21:11 kaloncheung124

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

stale[bot] avatar Jul 24 '19 22:07 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Jul 31 '19 23:07 stale[bot]