Commit 0e86357c authored by Lev Vidrak's avatar Lev Vidrak Committed by GitHub

Merge pull request #244 from RocketChat/master

[FIX] Android 8
parents 2c71cd91 cb77df5a
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "25"
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
......@@ -20,7 +20,7 @@ android {
dependencies {
// Google's GCM.
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile 'com.facebook.react:react-native:+'
......
package com.wix.reactnativenotifications.core.notification;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import com.facebook.react.bridge.ReactContext;
......@@ -136,13 +138,28 @@ public class PushNotification implements IPushNotification {
}
protected Notification.Builder getNotificationBuilder(PendingIntent intent) {
return new Notification.Builder(mContext)
String CHANNEL_ID = "channel_01";
String CHANNEL_NAME = "Channel Name";
final Notification.Builder notification = new Notification.Builder(mContext)
.setContentTitle(mNotificationProps.getTitle())
.setContentText(mNotificationProps.getBody())
.setSmallIcon(mContext.getApplicationInfo().icon)
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT);
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
notification.setChannelId(CHANNEL_ID);
}
return notification;
}
protected int postNotification(Notification notification, Integer notificationId) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment