33
33
import android .util .Base64 ;
34
34
35
35
import android .support .annotation .NonNull ;
36
+ import android .support .annotation .WorkerThread ;
36
37
38
+ import com .google .android .gms .tasks .Task ;
39
+ import com .google .android .gms .tasks .Tasks ;
37
40
import com .google .firebase .FirebaseApp ;
38
41
import com .google .firebase .FirebaseOptions ;
39
42
import com .google .firebase .iid .FirebaseInstanceId ;
40
43
import com .google .firebase .iid .FirebaseInstanceIdService ;
41
44
import com .google .firebase .messaging .FirebaseMessaging ;
42
45
46
+ import java .io .IOException ;
47
+ import java .util .concurrent .ExecutionException ;
48
+
43
49
// TODO: 4.0.0 - Switch to using <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
44
50
// Note: Starting with Firebase Messaging 17.1.0 onNewToken in FirebaseMessagingService should be
45
51
// used instead.
46
-
47
52
class PushRegistratorFCM extends PushRegistratorAbstractGoogle {
48
53
49
54
// project_info.project_id
@@ -88,8 +93,9 @@ String getProviderName() {
88
93
return "FCM" ;
89
94
}
90
95
96
+ @ WorkerThread
91
97
@ Override
92
- String getToken (String senderId ) throws Throwable {
98
+ String getToken (String senderId ) throws ExecutionException , InterruptedException , IOException {
93
99
initFirebaseApp (senderId );
94
100
95
101
try {
@@ -106,6 +112,7 @@ String getToken(String senderId) throws Throwable {
106
112
return getTokenWithClassFirebaseInstanceId (senderId );
107
113
}
108
114
115
+ @ WorkerThread
109
116
private String getTokenWithClassFirebaseInstanceId (String senderId ) throws IOException {
110
117
FirebaseInstanceId instanceId = FirebaseInstanceId .getInstance (firebaseApp );
111
118
return instanceId .getToken (senderId , FirebaseMessaging .INSTANCE_ID_SCOPE );
0 commit comments