查看迁移文档,看起来假设我的整个构建环境(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);
迁移需要进行哪些最小的更改?