google fcm使用sdk推送

java文件
notification和用谷歌后台推送是一样的效果,
因为老版本的APP没有字段区分安卓和IOS,所以直接使用了两种不同的推送方式。
比较奇葩,根据自己的需求改动把。。

/**
 * Created by xuzhen on 9/26/18.
 */
public class MessageGoogleUtil {
   
    private static final Logger logger = Logger.getLogger(MessageGoogleUtil.class);

    private static Map<String, FirebaseApp> firebaseAppMap = new ConcurrentHashMap<>();

    private static Map<String, Map<String, String>> goolPush = new HashMap<>();

    static {
   
        //配置多个推送配置
        Map<String, String> AOptions = new HashMap<>();
        readwardOptions.put("json", "xxxxxx");//你从官网下载的json文件放的路径
        readwardOptions.put("url", "xxxxxxxx");//https://xxxx.firebaseio.com/
        goolPush.put("A名字", AOptions);

        Map<String, String> BOptions = new HashMap<>();
        cashzineOptions.put("json", "xxxxxxx");
        cashzineOptions.put("url", "xxxxxx");
        goolPush.put("B名字", BOptions);
    }

    /**
     * 获取实例
     *
     * @param channelCode 渠道名作为应用名,获取初始化配置
     * @return
     */
    private static FirebaseMessaging getMessageInstance(String channelCode) {
   
        try {
   
            FirebaseApp firebaseApp = firebaseAppMap.get(channelCode);
            if (firebaseApp == null) {
   

                Map<String, String> firebaseConfig = goolPush.get(channelCode);
                if (firebaseConfig == null) {
   
                    return null;
                }
                FirebaseOptions options = new FirebaseOptions.Builder()                        .setCredentials
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值