facebookarchive / FBNotifications

Facebook Analytics In-App Notifications Framework
https://developers.facebook.com/products/push-campaigns
Other
493 stars 74 forks source link

In-App notifications does not work with Android Oreo #47

Open Veeresh8 opened 6 years ago

Veeresh8 commented 6 years ago

Recently tested out the library where the push notifications work properly (Adding notification channels) with Android Oreo but in-app notifications do not work. Please give an option to provide notification channels for in-app notifications.

soniccat commented 6 years ago

That can be done this way:

NotificationsManager.presentNotification(context, extras, ..., new NotificationsManager.NotificationExtender() {
@Override
public Notification.Builder extendNotification(@NonNull Notification.Builder notification) {
 String channelId = getString(R.string.news_channel_id);
                if (Constants.SUPPORT_OREO) {
                    notification.setChannelId(channelId);
                }
                notification.setSmallIcon(getIconRes());
                return notification;
            }
        });
Veeresh8 commented 6 years ago

Is this for in-app notification or the push notification?

soniccat commented 6 years ago

hm, I see some code was cut, it's for in-app notifications, updated code above, it's used with NotificationsManager.presentNotification

Veeresh8 commented 6 years ago

I can't seem to add the method there, I'm using the gradle dependency. Should I download and include as Library?

soniccat commented 6 years ago

@Veeresh8 we use the gradle dependency too 'com.facebook.android:notifications:1.0.2'. Can you see that with notificationExtender?:

  public static void presentNotification(
    @NonNull final Context context,
    @NonNull final Bundle notificationBundle,
    @NonNull final Intent launcherIntent,
    @Nullable final NotificationExtender notificationExtender) {

you need to pass a NotificationExtender object

Veeresh8 commented 6 years ago

Oh, Okay. Thanks!

Veeresh8 commented 6 years ago

What is the notification object here?

soniccat commented 6 years ago

it's an argument ... its Notification.Builder