use of android.app.NotificationChannel in project OneSignal-Android-SDK by OneSignal.
the class NotificationChannelManagerRunner method handleInvalidColorCode.
@Test
@Config(shadows = { ShadowOneSignal.class })
public void handleInvalidColorCode() throws Exception {
JSONObject payload = new JSONObject();
JSONObject chnl = new JSONObject();
chnl.put("id", "test_id");
chnl.put("nm", "Test Name");
payload.put("ledc", "FFFFFFFFY");
payload.put("chnl", chnl.toString());
NotificationChannelManager_createNotificationChannel(blankActivity, payload);
// check default to white
NotificationChannel channel = ShadowRoboNotificationManager.lastChannel;
BigInteger ledColor = new BigInteger("FFFFFFFF", 16);
assertEquals(ledColor.intValue(), channel.getLightColor());
assertTrue(ShadowOneSignal.messages.contains("OneSignal LED Color Settings: ARGB Hex value incorrect format (E.g: FF9900FF)"));
}
use of android.app.NotificationChannel in project OneSignal-Android-SDK by OneSignal.
the class NotificationChannelManagerRunner method createNotificationChannelShouldReturnDefaultChannelWithEmptyPayload.
@Test
public void createNotificationChannelShouldReturnDefaultChannelWithEmptyPayload() {
JSONObject payload = new JSONObject();
String ret = NotificationChannelManager_createNotificationChannel(blankActivity, payload);
assertEquals("fcm_fallback_notification_channel", ret);
NotificationChannel lastChannel = ShadowRoboNotificationManager.lastChannel;
assertEquals("fcm_fallback_notification_channel", lastChannel.getId());
assertNotNull(lastChannel.getSound());
assertTrue(lastChannel.shouldShowLights());
assertTrue(lastChannel.shouldVibrate());
}
use of android.app.NotificationChannel in project routerkeygenAndroid by routerkeygen.
the class NotificationUtils method initChannels.
static void initChannels(Context context) {
if (Build.VERSION.SDK_INT < 26 || channelCreated) {
return;
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(NotificationCompat.CATEGORY_SERVICE, context.getString(R.string.app_name), NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Channel description");
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
channelCreated = true;
}
use of android.app.NotificationChannel in project robolectric by robolectric.
the class ShadowNotificationManagerTest method createNotificationChannel.
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void createNotificationChannel() {
notificationManager.createNotificationChannel(new NotificationChannel("id", "name", 1));
assertThat(shadowOf(notificationManager).getNotificationChannels()).hasSize(1);
NotificationChannel channel = (NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id");
assertThat(channel.getName().toString()).isEqualTo("name");
assertThat(channel.getImportance()).isEqualTo(1);
}
use of android.app.NotificationChannel in project robolectric by robolectric.
the class ShadowNotificationManagerTest method createNotificationChannel_updateChannel.
@Test
@Config(minSdk = Build.VERSION_CODES.O)
public void createNotificationChannel_updateChannel() {
NotificationChannel channel = new NotificationChannel("id", "name", 1);
channel.setDescription("description");
channel.setGroup("channelGroupId");
channel.setLightColor(7);
NotificationChannel channelUpdate = new NotificationChannel("id", "newName", 2);
channelUpdate.setDescription("newDescription");
channelUpdate.setGroup("newChannelGroupId");
channelUpdate.setLightColor(15);
notificationManager.createNotificationChannel(channel);
notificationManager.createNotificationChannel(channelUpdate);
assertThat(shadowOf(notificationManager).getNotificationChannels()).hasSize(1);
NotificationChannel resultChannel = (NotificationChannel) shadowOf(notificationManager).getNotificationChannel("id");
assertThat(resultChannel.getName().toString()).isEqualTo("newName");
assertThat(resultChannel.getDescription()).isEqualTo("newDescription");
// No importance upgrade.
assertThat(resultChannel.getImportance()).isEqualTo(1);
// No group resultChannel.
assertThat(resultChannel.getGroup()).isEqualTo("channelGroupId");
// Other settings are unchanged as well.
assertThat(resultChannel.getLightColor()).isEqualTo(7);
}
Aggregations