[FIX] Android 8 notifications (#382)
<!-- INSTRUCTION: Keep the line below to notify all core developers about this new PR --> @RocketChat/ReactNative <!-- INSTRUCTION: Inform the issue number that this PR closes, or remove the line below --> Closes #380 <!-- INSTRUCTION: Tell us more about your PR with screen shots if you can -->
This commit is contained in:
parent
9d66a68bfd
commit
3b18216070
|
@ -1,6 +1,8 @@
|
|||
package chat.rocket.reactnative;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
@ -8,6 +10,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.BitmapFactory;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings.System;
|
||||
import android.media.RingtoneManager;
|
||||
|
@ -33,8 +36,10 @@ public class CustomPushNotification extends PushNotification {
|
|||
String title = bundle.getString("title");
|
||||
String message = bundle.getString("message");
|
||||
|
||||
final Notification.Builder notification = new Notification.Builder(mContext);
|
||||
notification
|
||||
String CHANNEL_ID = "rocketchatrn_channel_01";
|
||||
String CHANNEL_NAME = "All";
|
||||
|
||||
final Notification.Builder notification = new Notification.Builder(mContext)
|
||||
.setSmallIcon(smallIconResId)
|
||||
.setContentIntent(intent)
|
||||
.setContentTitle(title)
|
||||
|
@ -45,6 +50,17 @@ public class CustomPushNotification extends PushNotification {
|
|||
.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);
|
||||
}
|
||||
|
||||
Bitmap largeIconBitmap = BitmapFactory.decodeResource(res, largeIconResId);
|
||||
notification.setLargeIcon(largeIconBitmap);
|
||||
|
||||
|
|
|
@ -16105,9 +16105,8 @@
|
|||
}
|
||||
},
|
||||
"react-native-notifications": {
|
||||
"version": "1.1.19",
|
||||
"resolved": "https://registry.npmjs.org/react-native-notifications/-/react-native-notifications-1.1.19.tgz",
|
||||
"integrity": "sha512-s0zHNBzuskKnCVjQJ92A2x0b+ZZGEjg+Rp5Mmrx6ei0NRZpi85n8QOsINYNLyFrWcBLJKFc/pjXR8+VYUO4xyw==",
|
||||
"version": "git+https://github.com/RocketChat/react-native-notifications.git#cb77df5a4d3b5d2e48f6abaeb9acb60c8cfd2149",
|
||||
"from": "git+https://github.com/RocketChat/react-native-notifications.git",
|
||||
"requires": {
|
||||
"core-js": "^1.0.0",
|
||||
"uuid": "^2.0.3"
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
"react-native-meteor": "^1.4.0",
|
||||
"react-native-modal": "^6.4.0",
|
||||
"react-native-navigation": "^1.1.474",
|
||||
"react-native-notifications": "^1.1.19",
|
||||
"react-native-notifications": "git+https://github.com/RocketChat/react-native-notifications.git",
|
||||
"react-native-optimized-flatlist": "^1.0.4",
|
||||
"react-native-picker-select": "^4.0.0",
|
||||
"react-native-responsive-ui": "^1.1.1",
|
||||
|
|
Loading…
Reference in New Issue