当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseMessaging.getInstance方法代码示例

本文整理汇总了Java中com.google.firebase.messaging.FirebaseMessaging.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseMessaging.getInstance方法的具体用法?Java FirebaseMessaging.getInstance怎么用?Java FirebaseMessaging.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.messaging.FirebaseMessaging的用法示例。


在下文中一共展示了FirebaseMessaging.getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public void sendMessage (final String data) {
	FirebaseMessaging fm = FirebaseMessaging.getInstance();

	String token = FirebaseInstanceId.getInstance().getToken();
	String msgID = DigestUtils.sha1Hex(token + System.currentTimeMillis());
	String SENDER_ID = "someID";

	RemoteMessage.Builder RMBuilder =
	new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com");
	RMBuilder.setMessageId(msgID);

	Map<String, Object> mapData = Utils.jsonToMap(data);

	for (Map.Entry<String, Object> entry : mapData.entrySet()) {
		RMBuilder.addData(entry.getKey(), entry.getValue().toString());
	}

	fm.send(RMBuilder.build());
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:20,代码来源:Notification.java

示例2: 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);
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:21,代码来源:FcmUtilities.java

示例3: 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);
        }
    }
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:29,代码来源:MainService.java

示例4: send

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@ReactMethod
public void send(String senderId, ReadableMap payload) throws Exception {
    FirebaseMessaging fm = FirebaseMessaging.getInstance();
    RemoteMessage.Builder message = new RemoteMessage.Builder(senderId + "@gcm.googleapis.com")
    .setMessageId(UUID.randomUUID().toString());

    ReadableMapKeySetIterator iterator = payload.keySetIterator();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        String value = getStringFromReadableMap(payload, key);
        message.addData(key, value);
    }
    fm.send(message.build());
}
 
开发者ID:evollu,项目名称:react-native-fcm,代码行数:15,代码来源:FIRMessagingModule.java

示例5: fmSend

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
private static void fmSend(Bundle data) {
    final FirebaseMessaging fm = FirebaseMessaging.getInstance();
    if (senderid != null) {
        fm.send(new RemoteMessage.Builder(senderid + "@gcm.googleapis.com")
                .setMessageId(Integer.toString(msgId.incrementAndGet()))
                .setData(JoH.bundleToMap(data))
                .build());
    } else {
        Log.wtf(TAG, "senderid is null");
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:12,代码来源:GcmActivity.java

示例6: send

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@ReactMethod
public void send(String senderId, String messageId, String messageType, ReadableMap params, final Callback callback) {
    FirebaseMessaging fm = FirebaseMessaging.getInstance();
    RemoteMessage.Builder remoteMessage = new RemoteMessage.Builder(senderId);
    remoteMessage.setMessageId(messageId);
    remoteMessage.setMessageType(messageType);
    ReadableMapKeySetIterator iterator = params.keySetIterator();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType type = params.getType(key);
        if (type == ReadableType.String) {
            remoteMessage.addData(key, params.getString(key));
            Log.d(TAG, "Firebase send: " + key);
            Log.d(TAG, "Firebase send: " + params.getString(key));
        }
    }
    try {
        fm.send(remoteMessage.build());
        WritableMap res = Arguments.createMap();
        res.putString("status", "success");
        callback.invoke(null, res);
    } catch(Exception e) {
        Log.e(TAG, "Error sending message", e);
        WritableMap error = Arguments.createMap();
        error.putString("code", e.toString());
        error.putString("message", e.toString());
        callback.invoke(error);
    }
}
 
开发者ID:fullstackreact,项目名称:react-native-firestack,代码行数:30,代码来源:FirestackCloudMessaging.java

示例7: run

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@Override
public void run() {
  FirebaseMessaging fcm = FirebaseMessaging.getInstance();
  AtomicInteger msgId = new AtomicInteger();
  String id = Integer.toString(msgId.incrementAndGet());

  fcm.send(new RemoteMessage.Builder(gcmSenderId+"@gcm.googleapis.com")
  .setMessageId(id)
  .addData(ACTION, DISMISS_NOTIFICATION)
  .addData(NID, nid)
  .build());

}
 
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-push,代码行数:14,代码来源:MFPPush.java

示例8: subscribe

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public void subscribe(String topic){
    FirebaseMessaging messaging= FirebaseMessaging.getInstance();
    messaging.subscribeToTopic(topic);
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:5,代码来源:FireMessagingService.java

示例9: get

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@Override
public FirebaseMessaging get(Object... context) {
    return FirebaseMessaging.getInstance();
}
 
开发者ID:aerogear,项目名称:aerogear-android-push,代码行数:5,代码来源:AeroGearFCMPushRegistrar.java

示例10: getFirebaseMessaging

import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public static FirebaseMessaging getFirebaseMessaging() {

        return FirebaseMessaging.getInstance();
    }
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:5,代码来源:Library.java


注:本文中的com.google.firebase.messaging.FirebaseMessaging.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。