Created
February 18, 2018 20:49
-
-
Save hiranya911/f3c516acac299eb94ef74668fa1ef496 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private static final String ANDROID_NEWS_ICON_RESOURCE = "news_alert_icon"; | |
private static final int APNS_NEWS_BADGE_RESOURCE = 42; | |
private static final String WEBPUSH_NEWS_ICON_URL = "https://auto.news.url/alert.png"; | |
public String sendAutoNewsAlert(String title, String body) throws Exception { | |
Message message = Message.builder() | |
.setNotification(new Notification(title, body)) | |
.setAndroidConfig(AndroidConfig.builder() | |
.setNotification(AndroidNotification.builder() | |
.setIcon(ANDROID_NEWS_ICON_RESOURCE) | |
.build()) | |
.build()) | |
.setApnsConfig(ApnsConfig.builder() | |
.setAps(Aps.builder() | |
.setBadge(APNS_NEWS_BADGE_RESOURCE) | |
.build()) | |
.build()) | |
.setWebpushConfig(WebpushConfig.builder() | |
.setNotification(new WebpushNotification(null, null, WEBPUSH_NEWS_ICON_URL)) | |
.build()) | |
.setTopic("auto-news") | |
.build(); | |
return FirebaseMessaging.getInstance().sendAsync(message).get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment