firebase - 如何迁移非常旧的 Android 应用 GCM->FCM,其中应用既是发送者又是接收者
问题描述
查看迁移文档,似乎这是在假设我的整个构建环境(gradle、插件、库)都是最新的。就我而言,它们已经 5 岁了,我不打算升级它们中的任何一个,因为我完全没有信心我不会最终陷入破碎的构建地狱。此外,这是一个我将在今年晚些时候用 PWA 替换的应用程序,因此迁移不需要面向未来或使用任何新功能。
因此,我正在寻找可能的最小步骤来迁移并防止应用程序崩溃。我想我在接收端有一个句柄,但我正在寻找有关注册和发送的建议。
我目前的代码是
// REGISTRATION
gcm = GoogleCloudMessaging.getInstance(context);
MyLog.d("[G152] about to register with gcm...");
regid = gcm.register(SENDER_ID);
msg = "Device registered, registration ID=" + regid;
// SENDING
final String API_KEY = "AIzaAt-kduR...xDass";
URL url = new URL("https://android.googleapis.com/gcm/send");
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://android.googleapis.com/gcm/send");
httppost.setHeader("Content-Type", "application/json");
httppost.setHeader("Authorization", "key=" + API_KEY);
StringEntity body = new StringEntity(new Gson().toJson(gcMessage));
httppost.setEntity(body);
HttpResponse response = httpclient.execute(httppost);
迁移需要做的最小更改是什么?
解决方案
推荐阅读
- node.js - 在 Mac 上降级 NPM 版本
- sql - 这是表示一个表的一对多关系的好方法吗?
- c# - 从内存中读取 XML
- python - 导入 fbprophet 后烧瓶重复日志
- html - 在 SAS 宏变量中过去时如何保持 HTML 文本区域的布局?
- docker-swarm - Docker Swarm:处于分配状态的流量
- fiware-sth-comet - STH Comet - mongo 数据库中的原始插入
- python - Python-opencv:'ASSERT:文件 qasciikey.cpp 中的“false”'在俄语按键上
- flutter - Flutter:将一行切成“一半”
- typescript - 如何对包括子数组在内的对象值进行深度扫描