Skip to content

Commit

Permalink
Allow push notifications on Android Oreo (#952)
Browse files Browse the repository at this point in the history
* Handle channelId if specified

With Android Oreo it is necessary to specify a channel id when
sending out push notifications. This will check if such an
id is specified and in case it is available it will be set
on notification before it is being built

* Upgrade compile/build for Oreo

With Android Oreo it's necessary to specify a
channelId for push notifications to be handled.

This will bump gradle to allow for using those new methods
  • Loading branch information
theill authored and Nidhi Sharma committed May 31, 2018
1 parent f43ea84 commit 5246439
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/aws-amplify-react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ allprojects {
apply plugin: "com.android.library"

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 26
buildToolsVersion "26.0.1"

defaultConfig {
minSdkVersion 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void sendToNotificationCentre(Bundle bundle) {
if (msg == null) {
// this happens when a 'data' notification is received - we do not synthesize a local notification in this case
Log.d(LOG_TAG, "Cannot send to notification centre because there is no 'message' field in: " + bundle);
return;
return;
}
}

Expand Down Expand Up @@ -289,6 +289,13 @@ public void sendToNotificationCentre(Bundle bundle) {
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = bundle.getString("android_channel_id");
if (channelId != null) {
notification.setChannelId(channelId);
}
}

int notificationID = Integer.parseInt(notificationIdString);

PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent,
Expand Down

0 comments on commit 5246439

Please sign in to comment.