React-native-notifications: display notification when application state is "dead"

Created on 27 Dec 2016  路  10Comments  路  Source: wix/react-native-notifications

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?

Androicore bug 馃彋 stale

Most helpful comment

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 :(

All 10 comments

Same issue in here.

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

Is this still relevant?

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

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 :(

Sure, thank you!

Any updates on this?

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;
    }
}

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.

The issue has been closed for inactivity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bilal-Abdeen picture Bilal-Abdeen  路  4Comments

TheMisir picture TheMisir  路  4Comments

ghost picture ghost  路  3Comments

moonjava2005 picture moonjava2005  路  5Comments

fosteruk picture fosteruk  路  5Comments