本文整理汇总了Java中com.google.firebase.messaging.FirebaseMessaging.unsubscribeFromTopic方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseMessaging.unsubscribeFromTopic方法的具体用法?Java FirebaseMessaging.unsubscribeFromTopic怎么用?Java FirebaseMessaging.unsubscribeFromTopic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.messaging.FirebaseMessaging
的用法示例。
在下文中一共展示了FirebaseMessaging.unsubscribeFromTopic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeTopics
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public static void subscribeTopics(boolean isConfMessageCardsEnabled, boolean isRegisteredAttendee) {
try {
FirebaseMessaging pubSub = FirebaseMessaging.getInstance();
if (isConfMessageCardsEnabled) {
if (isRegisteredAttendee) {
pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
pubSub.subscribeToTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
} else {
pubSub.subscribeToTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
}
} else {
pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
}
} catch (Throwable throwable) {
// Just in case.
LOGE(TAG, "Exception updating conference message cards subscription.", throwable);
}
}
示例2: reloadFCMsubscriptions
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public void reloadFCMsubscriptions() {
FirebaseMessaging fcm = FirebaseMessaging.getInstance();
SharedPreferences sharedPref = getSharedPreferences("notifsettings", MODE_PRIVATE);
Set<String> linePref = sharedPref.getStringSet("pref_notifs_lines", null);
if (linePref != null && linePref.size() != 0) {
fcm.subscribeToTopic("disturbances");
if (BuildConfig.DEBUG) {
fcm.subscribeToTopic("disturbances-debug");
}
} else {
fcm.unsubscribeFromTopic("disturbances");
fcm.unsubscribeFromTopic("disturbances-debug");
}
Set<String> sourcePref = sharedPref.getStringSet("pref_notifs_announcement_sources", null);
for (Announcement.Source possibleSource : Announcement.getSources()) {
if (sourcePref != null && sourcePref.contains(possibleSource.id)) {
fcm.subscribeToTopic("announcements-" + possibleSource.id);
if (BuildConfig.DEBUG) {
fcm.subscribeToTopic("announcements-debug-" + possibleSource.id);
}
} else {
fcm.unsubscribeFromTopic("announcements-" + possibleSource.id);
fcm.unsubscribeFromTopic("announcements-debug-" + possibleSource.id);
}
}
}