use of se.oort.diplicity.apigen.FCMNotificationConfig in project android-diplicity by zond.
the class RetrofitActivity method updateFCMPushOption.
public void updateFCMPushOption(UserConfig userConfig, boolean newValue, String message) {
FCMToken pushToken = getFCMToken(userConfig);
if (newValue) {
if (pushToken == null) {
pushToken = new FCMToken();
pushToken.Note = message + " at " + new Date();
if (userConfig.FCMTokens == null) {
userConfig.FCMTokens = new ArrayList<FCMToken>();
}
userConfig.FCMTokens.add(pushToken);
} else if (pushToken.Disabled) {
pushToken.Note = message + " at " + new Date();
}
pushToken.Disabled = false;
pushToken.Value = FirebaseInstanceId.getInstance().getToken();
pushToken.App = APP_NAME;
pushToken.ReplaceToken = new BigInteger(8 * 24, random).toString(32);
pushToken.MessageConfig = new FCMNotificationConfig();
pushToken.MessageConfig.ClickActionTemplate = MessagingService.FCM_NOTIFY_ACTION;
pushToken.PhaseConfig = new FCMNotificationConfig();
pushToken.PhaseConfig.ClickActionTemplate = MessagingService.FCM_NOTIFY_ACTION;
} else {
if (pushToken != null && (pushToken.Disabled == null || !pushToken.Disabled)) {
pushToken.Disabled = true;
pushToken.Note = message + " at " + new Date();
}
}
if (pushToken != null) {
final FCMToken finalToken = pushToken;
handleReq(userConfigService.UserConfigUpdate(userConfig, getLoggedInUser().Id), new Sendable<SingleContainer<UserConfig>>() {
@Override
public void send(SingleContainer<UserConfig> userConfigSingleContainer) {
PreferenceManager.getDefaultSharedPreferences(RetrofitActivity.this).edit().putString(FCM_REPLACE_TOKEN_PREF_KEY, finalToken.ReplaceToken).apply();
}
}, getResources().getString(R.string.updating_settings));
}
}
Aggregations