Translate

Thursday, April 30, 2020

Android code to turn-on/Enable and turn-off/Disable receiving Braze push/silent notifications in Android device

notificationEnableDisable.setOnCheckedChangeListener((buttonView, isChecked) -> {
    if (isChecked) {
        register();
    } else {
        unregister();
    }
});

//To Turnon receiving Braze notifications in Android app...void register() {
    // Need to register push notifications with current device token    com.package.Appboy appboy = com.package.Appboy.getInstance(context);
    String deviceToken = FirebaseInstanceId.getInstance().getToken();
    if (Strings.isNonEmpty(deviceToken)) {
        appboy.registerAppboyPushMessages(deviceToken);
    }
}

//To Turnoff receiving Braze notifications in Android app...void unregister() {
    com.package.Appboy appboy = com.package.Appboy.getInstance(context);

    AppboyUser user = appboy.getCurrentUser();
    if (user != null) {
        user.setPushNotificationSubscriptionType("unsubscribed");

    }
}


No comments:

Post a Comment

Could not identify launch activity: Default activity not found : Error while Launching activity

Problem : I got this Error , When I tried to create an application without any Activity . Basically like to develop an Android Headless appl...