mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Fix FCM not initialized crash.
This commit is contained in:
committed by
Greyson Parrelli
parent
2eb933c2d4
commit
5df20d755a
@@ -1,10 +1,12 @@
|
||||
package org.thoughtcrime.securesms.gcm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.google.android.gms.tasks.Tasks;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
@@ -20,8 +22,12 @@ public final class FcmUtil {
|
||||
* Retrieves the current FCM token. If one isn't available, it'll be generated.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static Optional<String> getToken() {
|
||||
public static Optional<String> getToken(Context context) {
|
||||
String token = null;
|
||||
|
||||
// Must be called manually if running outside of main process
|
||||
FirebaseApp.initializeApp(context);
|
||||
|
||||
try {
|
||||
token = Tasks.await(FirebaseMessaging.getInstance().getToken());
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
Reference in New Issue
Block a user