@@ -20,11 +20,15 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
20
20
required CallNotificationWrapper callNotification,
21
21
required StreamVideoPushNotificationMethodChannel methodChannel,
22
22
required StreamVideoPushNotificationEventChannel eventChannel,
23
+ String ? firebaseProviderName,
24
+ String ? apnsProviderName,
23
25
}) : _client = client,
24
26
_callNotification = callNotification,
25
27
_sharedPreferences = sharedPreferences,
26
28
_methodChannel = methodChannel,
27
- _eventChannel = eventChannel {
29
+ _eventChannel = eventChannel,
30
+ _firebaseProviderName = firebaseProviderName,
31
+ _apnsProviderName = apnsProviderName {
28
32
_eventChannel.onEvent.listen ((event) {
29
33
if (event.type == NativeEventType .ACTION_INCOMING_CALL ) {
30
34
_showCall (event.content['call_cid' ]);
@@ -38,6 +42,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
38
42
final SharedPreferences _sharedPreferences;
39
43
final StreamVideoPushNotificationMethodChannel _methodChannel;
40
44
final StreamVideoPushNotificationEventChannel _eventChannel;
45
+ final String ? _firebaseProviderName;
46
+ final String ? _apnsProviderName;
41
47
42
48
@override
43
49
Future <void > onUserLoggedIn () async {
@@ -49,6 +55,11 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
49
55
}
50
56
51
57
Future <void > _registerAndroidDevice () async {
58
+ if (_firebaseProviderName == null ) {
59
+ _logger.w (() => '[registerAndroidDevice] No Firebase provider name set' );
60
+ return ;
61
+ }
62
+
52
63
if (_isFirebaseInitialized ()) {
53
64
FirebaseMessaging .instance.onTokenRefresh.listen ((token) async {
54
65
_logger.d (() => '[registerAndroidDevice] refreshedToken: $token ' );
@@ -65,14 +76,19 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
65
76
}
66
77
67
78
Future <void > _registerIOSDevice () async {
79
+ if (_apnsProviderName == null ) {
80
+ _logger.w (() => '[registerIOSDevice] No APNS provider name set' );
81
+ return ;
82
+ }
83
+
68
84
final token = await _methodChannel.getDevicePushTokenVoIP ();
69
85
_logger.d (() => '[registerIOSDevice] token: $token ' );
70
86
if (token != null ) {
71
87
await _client.createDevice (
72
88
id: token,
73
89
voipToken: true ,
74
90
pushProvider: CreateDeviceRequestPushProviderEnum .apn,
75
- pushProviderName: 'flutter-apn-video' ,
91
+ pushProviderName: _apnsProviderName ,
76
92
);
77
93
}
78
94
}
@@ -81,7 +97,7 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
81
97
await _client.createDevice (
82
98
id: token,
83
99
pushProvider: CreateDeviceRequestPushProviderEnum .firebase,
84
- pushProviderName: 'firebase' ,
100
+ pushProviderName: _firebaseProviderName ,
85
101
);
86
102
}
87
103
@@ -209,6 +225,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
209
225
}
210
226
211
227
static PushNotificationManagerFactory factory ({
228
+ String ? firebaseProviderName,
229
+ String ? apnsProviderName,
212
230
SharedPreferences ? sharedPreferences,
213
231
CallNotificationWrapper ? callNotification,
214
232
StreamVideoPushNotificationMethodChannel ? methodChannel,
@@ -224,6 +242,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
224
242
methodChannel ?? const StreamVideoPushNotificationMethodChannel (),
225
243
eventChannel:
226
244
eventChannel ?? const StreamVideoPushNotificationEventChannel (),
245
+ apnsProviderName: apnsProviderName,
246
+ firebaseProviderName: firebaseProviderName,
227
247
);
228
248
};
229
249
}
0 commit comments