Skip to content

Commit 3c20cba

Browse files
deven98Nash0x7E2
authored andcommitted
adds provider name confifuration for Firebase and APNS
1 parent f5fe2ed commit 3c20cba

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

dogfooding/lib/repos/app_repository.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class AppRepository {
3232
muteVideoWhenInBackground: true,
3333
);
3434
await streamVideoClient.initPushNotificationManager(
35-
StreamVideoPushNotificationManager.factory(),
35+
StreamVideoPushNotificationManager.factory(
36+
apnsProviderName: 'flutter-apn-video',
37+
firebaseProviderName: 'firebase',
38+
),
3639
);
3740
return streamVideoClient;
3841
} else {

packages/stream_video_push_notification/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.3
2+
3+
* Adds ability to update provider names for Firebase and APNS
4+
15
## 0.0.2
26

37
* Updates for backend

packages/stream_video_push_notification/lib/stream_video_push_notification.dart

+23-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
2020
required CallNotificationWrapper callNotification,
2121
required StreamVideoPushNotificationMethodChannel methodChannel,
2222
required StreamVideoPushNotificationEventChannel eventChannel,
23+
String? firebaseProviderName,
24+
String? apnsProviderName,
2325
}) : _client = client,
2426
_callNotification = callNotification,
2527
_sharedPreferences = sharedPreferences,
2628
_methodChannel = methodChannel,
27-
_eventChannel = eventChannel {
29+
_eventChannel = eventChannel,
30+
_firebaseProviderName = firebaseProviderName,
31+
_apnsProviderName = apnsProviderName {
2832
_eventChannel.onEvent.listen((event) {
2933
if (event.type == NativeEventType.ACTION_INCOMING_CALL) {
3034
_showCall(event.content['call_cid']);
@@ -38,6 +42,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
3842
final SharedPreferences _sharedPreferences;
3943
final StreamVideoPushNotificationMethodChannel _methodChannel;
4044
final StreamVideoPushNotificationEventChannel _eventChannel;
45+
final String? _firebaseProviderName;
46+
final String? _apnsProviderName;
4147

4248
@override
4349
Future<void> onUserLoggedIn() async {
@@ -49,6 +55,11 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
4955
}
5056

5157
Future<void> _registerAndroidDevice() async {
58+
if(_firebaseProviderName == null) {
59+
_logger.w(() => '[registerAndroidDevice] No Firebase provider name set');
60+
return;
61+
}
62+
5263
if (_isFirebaseInitialized()) {
5364
FirebaseMessaging.instance.onTokenRefresh.listen((token) async {
5465
_logger.d(() => '[registerAndroidDevice] refreshedToken: $token');
@@ -65,14 +76,19 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
6576
}
6677

6778
Future<void> _registerIOSDevice() async {
79+
if(_apnsProviderName == null) {
80+
_logger.w(() => '[registerIOSDevice] No APNS provider name set');
81+
return;
82+
}
83+
6884
final token = await _methodChannel.getDevicePushTokenVoIP();
6985
_logger.d(() => '[registerIOSDevice] token: $token');
7086
if (token != null) {
7187
await _client.createDevice(
7288
id: token,
7389
voipToken: true,
7490
pushProvider: CreateDeviceRequestPushProviderEnum.apn,
75-
pushProviderName: 'flutter-apn-video',
91+
pushProviderName: _apnsProviderName,
7692
);
7793
}
7894
}
@@ -81,7 +97,7 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
8197
await _client.createDevice(
8298
id: token,
8399
pushProvider: CreateDeviceRequestPushProviderEnum.firebase,
84-
pushProviderName: 'firebase',
100+
pushProviderName: _firebaseProviderName,
85101
);
86102
}
87103

@@ -209,6 +225,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
209225
}
210226

211227
static PushNotificationManagerFactory factory({
228+
String? firebaseProviderName,
229+
String? apnsProviderName,
212230
SharedPreferences? sharedPreferences,
213231
CallNotificationWrapper? callNotification,
214232
StreamVideoPushNotificationMethodChannel? methodChannel,
@@ -224,6 +242,8 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
224242
methodChannel ?? const StreamVideoPushNotificationMethodChannel(),
225243
eventChannel:
226244
eventChannel ?? const StreamVideoPushNotificationEventChannel(),
245+
apnsProviderName: apnsProviderName,
246+
firebaseProviderName: firebaseProviderName,
227247
);
228248
};
229249
}

packages/stream_video_push_notification/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: stream_video_push_notification
22
description: Adds push notification support for Stream Video, a service for building video calls, audio rooms, and live-streaming applications.
3-
version: 0.0.2
3+
version: 0.0.3
44
homepage: https://getstream.io/video/
55
repository: https://github.com/GetStream/stream-video-flutter
66
issue_tracker: https://github.com/GetStream/stream-video-flutter/issues

0 commit comments

Comments
 (0)