30
30
import android .util .Base64 ;
31
31
32
32
import androidx .annotation .NonNull ;
33
+ import androidx .annotation .WorkerThread ;
33
34
35
+ import com .google .android .gms .tasks .Task ;
36
+ import com .google .android .gms .tasks .Tasks ;
34
37
import com .google .firebase .FirebaseApp ;
35
38
import com .google .firebase .FirebaseOptions ;
36
39
import com .google .firebase .iid .FirebaseInstanceId ;
37
40
import com .google .firebase .messaging .FirebaseMessaging ;
38
41
42
+ import java .io .IOException ;
43
+ import java .util .concurrent .ExecutionException ;
44
+
39
45
class PushRegistratorFCM extends PushRegistratorAbstractGoogle {
40
46
41
47
// project_info.project_id
@@ -54,8 +60,9 @@ String getProviderName() {
54
60
return "FCM" ;
55
61
}
56
62
63
+ @ WorkerThread
57
64
@ Override
58
- String getToken (String senderId ) throws Throwable {
65
+ String getToken (String senderId ) throws ExecutionException , InterruptedException , IOException {
59
66
initFirebaseApp (senderId );
60
67
61
68
try {
@@ -72,6 +79,7 @@ String getToken(String senderId) throws Throwable {
72
79
return getTokenWithClassFirebaseInstanceId (senderId );
73
80
}
74
81
82
+ @ WorkerThread
75
83
private String getTokenWithClassFirebaseInstanceId (String senderId ) throws IOException {
76
84
FirebaseInstanceId instanceId = FirebaseInstanceId .getInstance (firebaseApp );
77
85
return instanceId .getToken (senderId , FirebaseMessaging .INSTANCE_ID_SCOPE );
0 commit comments