diff --git a/plugins/2020.3569/android/plugin.notifications.v2.jar b/plugins/2020.3569/android/plugin.notifications.v2.jar index 7a663f0..f4b989b 100644 Binary files a/plugins/2020.3569/android/plugin.notifications.v2.jar and b/plugins/2020.3569/android/plugin.notifications.v2.jar differ diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 9abf285..538b498 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -181,6 +181,11 @@ if (configureCoronaPlugins == "YES") { // android { + compileOptions { + sourceCompatibility = org.gradle.api.JavaVersion.VERSION_1_8 + targetCompatibility = org.gradle.api.JavaVersion.VERSION_1_8 + } + compileSdkVersion(29) defaultConfig { applicationId = coronaAppPackage diff --git a/src/android/plugin/build.gradle b/src/android/plugin/build.gradle index 96c5e53..2a0606f 100644 --- a/src/android/plugin/build.gradle +++ b/src/android/plugin/build.gradle @@ -2,6 +2,10 @@ apply plugin: 'com.android.library' android { compileSdkVersion 29 + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } defaultConfig { minSdkVersion 15 @@ -12,7 +16,7 @@ android { } dependencies { - implementation 'com.google.firebase:firebase-messaging:' + '20.2.3' + implementation 'com.google.firebase:firebase-messaging:22.0.0' implementation ':Corona@aar' } diff --git a/src/android/plugin/src/main/java/plugin/notifications/v2/LuaLoader.java b/src/android/plugin/src/main/java/plugin/notifications/v2/LuaLoader.java index 84fcfb2..c2998d7 100644 --- a/src/android/plugin/src/main/java/plugin/notifications/v2/LuaLoader.java +++ b/src/android/plugin/src/main/java/plugin/notifications/v2/LuaLoader.java @@ -14,6 +14,7 @@ import com.ansca.corona.CoronaRuntimeListener; import com.ansca.corona.Bridge; +import com.google.android.gms.tasks.Task; import com.naef.jnlua.LuaState; import com.naef.jnlua.JavaFunction; import com.naef.jnlua.LuaType; @@ -24,7 +25,6 @@ import android.util.Log; import com.google.firebase.messaging.FirebaseMessaging; -import com.google.firebase.iid.FirebaseInstanceId; /** * Implements the Lua interface for the plugin. @@ -194,7 +194,7 @@ public int invoke(LuaState L) { } // [Lua] registerForPushNotifications( {options} ) - private class RegisterForPushNotifications implements NamedJavaFunction { + private static class RegisterForPushNotifications implements NamedJavaFunction { /** * Gets the name of the Lua function as it would appear in the Lua script. * @@ -263,8 +263,12 @@ public int invoke(final LuaState luaState) { logMsg(ERROR_MSG, "Expected no arguments, got " + nargs); return 0; } - - String deviceToken = FirebaseInstanceId.getInstance().getToken(); + Task tokenTask = FirebaseMessaging.getInstance().getToken(); + try { + tokenTask.wait(1000); + } catch (InterruptedException ignore) { + } + String deviceToken = tokenTask.getResult(); if (deviceToken == null) { deviceToken = "unknown";