Created
August 24, 2017 18:37
-
-
Save karthiks/9cf6844da01aee0fd4f834b8579ad5c7 to your computer and use it in GitHub Desktop.
Create Notification object using Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NotificationUtils extends ContextWrapper { | |
public static final String ANDROID_CHANNEL_ID = "com.androidstuff.tutsplustalerts.ANDROID"; | |
public static final String IOS_CHANNEL_ID = "com.androidstuff.tutsplustalerts.IOS"; | |
public static final String ANDROID_CHANNEL_NAME = "ANDROID CHANNEL"; | |
public static final String IOS_CHANNEL_NAME = "IOS CHANNEL"; | |
private NotificationManager notificationManager; | |
public NotificationUtils(Context base) { | |
super(base); | |
createChannels(); | |
} | |
//.. | |
public Notification getAndroidChannelNotification(String title, String body) { | |
return new Notification.Builder(getApplicationContext(), ANDROID_CHANNEL_ID) | |
.setContentTitle(title) | |
.setContentText(body) | |
.setSmallIcon(android.R.drawable.stat_notify_more) | |
.setAutoCancel(true) | |
.build(); | |
} | |
public Notification getIosChannelNotification(String title, String body) { | |
return new Notification.Builder(getApplicationContext(), IOS_CHANNEL_ID) | |
.setContentTitle(title) | |
.setContentText(body) | |
.setSmallIcon(android.R.drawable.stat_notify_more) | |
.setAutoCancel(true) | |
.build(); | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment