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