如何迁移一个非常古老的Android应用程序GCM-> FCM,其中app既是发送者又是接收者

问题描述 投票:3回答:1

查看迁移文档,看起来假设我的整个构建环境(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);

迁移需要进行哪些最小的更改?

firebase google-cloud-platform google-cloud-messaging firebase-cloud-messaging
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.