Commit cb77df5a authored by Diego Mello's avatar Diego Mello

Update to SDK 27

parent 2c71cd91
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 23 compileSdkVersion 27
buildToolsVersion "25" buildToolsVersion "27.0.3"
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 19
targetSdkVersion 23 targetSdkVersion 27
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
} }
...@@ -20,7 +20,7 @@ android { ...@@ -20,7 +20,7 @@ android {
dependencies { dependencies {
// Google's GCM. // 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:+' compile 'com.facebook.react:react-native:+'
......
package com.wix.reactnativenotifications.core.notification; package com.wix.reactnativenotifications.core.notification;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
...@@ -136,13 +138,28 @@ public class PushNotification implements IPushNotification { ...@@ -136,13 +138,28 @@ public class PushNotification implements IPushNotification {
} }
protected Notification.Builder getNotificationBuilder(PendingIntent intent) { 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()) .setContentTitle(mNotificationProps.getTitle())
.setContentText(mNotificationProps.getBody()) .setContentText(mNotificationProps.getBody())
.setSmallIcon(mContext.getApplicationInfo().icon) .setSmallIcon(mContext.getApplicationInfo().icon)
.setContentIntent(intent) .setContentIntent(intent)
.setDefaults(Notification.DEFAULT_ALL) .setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true); .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) { 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