@cloudflare/realtimekit-react-native 0.2.0 → 0.2.1-staging.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/BroadcastEventEmitter.m +20 -1
- package/ios/RNInCallManager.m +62 -31
- package/ios/RTKRNBackgroundTimer.m +18 -3
- package/lib/commonjs/utils/version.js +1 -1
- package/lib/commonjs/utils/version.js.map +1 -1
- package/lib/module/utils/version.js +1 -1
- package/lib/module/utils/version.js.map +1 -1
- package/lib/typescript/utils/version.d.ts +1 -1
- package/package.json +2 -4
|
@@ -6,6 +6,23 @@ NSString *const BroadcastStartedNotification = @"iOS_BroadcastStarted";
|
|
|
6
6
|
NSString *const BroadcastStoppedNotification = @"iOS_BroadcastStopped";
|
|
7
7
|
|
|
8
8
|
@implementation BroadcastEventEmitter
|
|
9
|
+
{
|
|
10
|
+
bool hasListeners;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
- (BOOL)canSendEvents {
|
|
14
|
+
return self.bridge != nil;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Will be called when this module's first listener is added.
|
|
18
|
+
-(void)startObserving {
|
|
19
|
+
hasListeners = YES;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Will be called when this module's last listener is removed, or on dealloc.
|
|
23
|
+
-(void)stopObserving {
|
|
24
|
+
hasListeners = NO;
|
|
25
|
+
}
|
|
9
26
|
|
|
10
27
|
RCT_EXPORT_MODULE();
|
|
11
28
|
|
|
@@ -48,7 +65,9 @@ void broadcastEventCallback(CFNotificationCenterRef center,
|
|
|
48
65
|
// Handle incoming notifications and send events to React Native
|
|
49
66
|
- (void)handleNotification:(CFNotificationName)name {
|
|
50
67
|
NSString *eventName = (__bridge NSString *)name;
|
|
51
|
-
[self
|
|
68
|
+
if (hasListeners && [self canSendEvents]) {
|
|
69
|
+
[self sendEventWithName:eventName body:nil];
|
|
70
|
+
}
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
// Declare the supported event names
|
package/ios/RNInCallManager.m
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
{
|
|
12
12
|
|
|
13
13
|
UIDevice *_currentDevice;
|
|
14
|
+
bool hasListeners;
|
|
14
15
|
|
|
15
16
|
AVAudioSession *_audioSession;
|
|
16
17
|
AVAudioPlayer *_ringtone;
|
|
@@ -55,6 +56,22 @@
|
|
|
55
56
|
NSString *_media;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
- (BOOL)canSendEvents {
|
|
60
|
+
return self.bridge != nil;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Will be called when this module's first listener is added.
|
|
64
|
+
-(void)startObserving {
|
|
65
|
+
hasListeners = YES;
|
|
66
|
+
// Set up any upstream listeners or background tasks as necessary
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Will be called when this module's last listener is removed, or on dealloc.
|
|
70
|
+
-(void)stopObserving {
|
|
71
|
+
hasListeners = NO;
|
|
72
|
+
// Remove upstream listeners, stop unnecessary background tasks
|
|
73
|
+
}
|
|
74
|
+
|
|
58
75
|
+ (BOOL)requiresMainQueueSetup
|
|
59
76
|
{
|
|
60
77
|
return NO;
|
|
@@ -835,7 +852,9 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
835
852
|
// NSLog(@"RNInCallManager.UIDeviceProximityStateDidChangeNotification(): isNear: %@", state ? @"YES" : @"NO");
|
|
836
853
|
self->_proximityIsNear = state;
|
|
837
854
|
@try {
|
|
838
|
-
[self
|
|
855
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
856
|
+
[self sendEventWithName:@"Proximity" body:@{@"isNear": state ? @YES : @NO}];
|
|
857
|
+
}
|
|
839
858
|
} @catch (NSException *exception) {
|
|
840
859
|
NSLog(@"Error sending event 'Proximity': %@", exception.reason);
|
|
841
860
|
}
|
|
@@ -958,7 +977,7 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
958
977
|
|
|
959
978
|
NSNumber *routeChangeType = [notification.userInfo objectForKey:@"AVAudioSessionRouteChangeReasonKey"];
|
|
960
979
|
NSUInteger routeChangeTypeValue = [routeChangeType unsignedIntegerValue];
|
|
961
|
-
|
|
980
|
+
|
|
962
981
|
switch (routeChangeTypeValue) {
|
|
963
982
|
case AVAudioSessionRouteChangeReasonUnknown:
|
|
964
983
|
// NSLog(@"🧑💻 RNInCallManager.AudioRouteChange.Reason: Unknown");
|
|
@@ -969,11 +988,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
969
988
|
routeType:@"input"]) {
|
|
970
989
|
self->_forceSpeakerOn = 0;
|
|
971
990
|
@try {
|
|
972
|
-
[self
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
991
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
992
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
993
|
+
body:@{
|
|
994
|
+
@"availableAudioDeviceList": @"[speaker, earpiece, wired]",
|
|
995
|
+
@"selectedAudioDevice": @"wired",
|
|
996
|
+
}];
|
|
997
|
+
}
|
|
977
998
|
} @catch (NSException *exception) {
|
|
978
999
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (HeadsetMic): %@", exception.reason);
|
|
979
1000
|
}
|
|
@@ -981,11 +1002,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
981
1002
|
routeType:@"output"]) {
|
|
982
1003
|
self->_forceSpeakerOn = 0;
|
|
983
1004
|
@try {
|
|
984
|
-
[self
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1005
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
1006
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
1007
|
+
body:@{
|
|
1008
|
+
@"availableAudioDeviceList": @"[speaker, earpiece, wired]",
|
|
1009
|
+
@"selectedAudioDevice": @"wired",
|
|
1010
|
+
}];
|
|
1011
|
+
}
|
|
989
1012
|
} @catch (NSException *exception) {
|
|
990
1013
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (Headphones): %@", exception.reason);
|
|
991
1014
|
}
|
|
@@ -994,11 +1017,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
994
1017
|
self->_forceSpeakerOn = 0;
|
|
995
1018
|
[self routeAudioFromBluetooth];
|
|
996
1019
|
@try {
|
|
997
|
-
[self
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1020
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
1021
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
1022
|
+
body:@{
|
|
1023
|
+
@"availableAudioDeviceList": @"[speaker, earpiece, bluetooth]",
|
|
1024
|
+
@"selectedAudioDevice": @"bluetooth",
|
|
1025
|
+
}];
|
|
1026
|
+
}
|
|
1002
1027
|
} @catch (NSException *exception) {
|
|
1003
1028
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (BluetoothHFP): %@", exception.reason);
|
|
1004
1029
|
}
|
|
@@ -1007,11 +1032,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
1007
1032
|
self->_forceSpeakerOn = 0;
|
|
1008
1033
|
[self routeAudioFromBluetooth];
|
|
1009
1034
|
@try {
|
|
1010
|
-
[self
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1035
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
1036
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
1037
|
+
body:@{
|
|
1038
|
+
@"availableAudioDeviceList": @"[speaker, earpiece, bluetooth]",
|
|
1039
|
+
@"selectedAudioDevice": @"bluetooth",
|
|
1040
|
+
}];
|
|
1041
|
+
}
|
|
1015
1042
|
} @catch (NSException *exception) {
|
|
1016
1043
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (BluetoothA2DP): %@", exception.reason);
|
|
1017
1044
|
}
|
|
@@ -1020,11 +1047,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
1020
1047
|
self->_forceSpeakerOn = 0;
|
|
1021
1048
|
[self routeAudioFromBluetooth];
|
|
1022
1049
|
@try {
|
|
1023
|
-
[self
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1050
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
1051
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
1052
|
+
body:@{
|
|
1053
|
+
@"availableAudioDeviceList": @"[speaker, earpiece, bluetooth]",
|
|
1054
|
+
@"selectedAudioDevice": @"bluetooth",
|
|
1055
|
+
}];
|
|
1056
|
+
}
|
|
1028
1057
|
} @catch (NSException *exception) {
|
|
1029
1058
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (BluetoothLE): %@", exception.reason);
|
|
1030
1059
|
}
|
|
@@ -1032,11 +1061,13 @@ RCT_EXPORT_METHOD(isBluetoothHeadsetConnected: (RCTPromiseResolveBlock) resolve
|
|
|
1032
1061
|
break;
|
|
1033
1062
|
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
|
|
1034
1063
|
@try {
|
|
1035
|
-
[self
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1064
|
+
if (self->hasListeners && [self canSendEvents]) {
|
|
1065
|
+
[self sendEventWithName:@"onAudioDeviceChanged"
|
|
1066
|
+
body:@{
|
|
1067
|
+
@"availableAudioDeviceList": @"[speaker, earpiece]",
|
|
1068
|
+
@"selectedAudioDevice": @"speaker",
|
|
1039
1069
|
}];
|
|
1070
|
+
}
|
|
1040
1071
|
} @catch (NSException *exception) {
|
|
1041
1072
|
NSLog(@"Error sending event 'onAudioDeviceChanged' (OldDeviceUnavailable): %@", exception.reason);
|
|
1042
1073
|
}
|
|
@@ -11,6 +11,21 @@
|
|
|
11
11
|
@implementation RTKRNBackgroundTimer {
|
|
12
12
|
UIBackgroundTaskIdentifier bgTask;
|
|
13
13
|
int delay;
|
|
14
|
+
bool hasListeners;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
- (BOOL)canSendEvents {
|
|
18
|
+
return self.bridge != nil;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Will be called when this module's first listener is added.
|
|
22
|
+
-(void)startObserving {
|
|
23
|
+
hasListeners = YES;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Will be called when this module's last listener is removed, or on dealloc.
|
|
27
|
+
-(void)stopObserving {
|
|
28
|
+
hasListeners = NO;
|
|
14
29
|
}
|
|
15
30
|
|
|
16
31
|
RCT_EXPORT_MODULE()
|
|
@@ -29,7 +44,7 @@ RCT_EXPORT_MODULE()
|
|
|
29
44
|
|
|
30
45
|
UIBackgroundTaskIdentifier thisBgTask = bgTask;
|
|
31
46
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
32
|
-
if ([self
|
|
47
|
+
if (hasListeners && [self canSendEvents] && thisBgTask == bgTask) {
|
|
33
48
|
[self sendEventWithName:@"backgroundTimer" body:[NSNumber numberWithInt:(int)thisBgTask]];
|
|
34
49
|
}
|
|
35
50
|
});
|
|
@@ -69,7 +84,7 @@ RCT_EXPORT_METHOD(setTimeout:(int)timeoutId
|
|
|
69
84
|
}];
|
|
70
85
|
|
|
71
86
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, timeout * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
|
|
72
|
-
if ([self
|
|
87
|
+
if (hasListeners && [self canSendEvents]) {
|
|
73
88
|
[self sendEventWithName:@"backgroundTimer.timeout" body:[NSNumber numberWithInt:timeoutId]];
|
|
74
89
|
}
|
|
75
90
|
[[UIApplication sharedApplication] endBackgroundTask:task];
|
|
@@ -81,7 +96,7 @@ RCT_EXPORT_METHOD(backgroundTimerSetTimeout:(int)timeoutId
|
|
|
81
96
|
timeout:(double)timeout)
|
|
82
97
|
{
|
|
83
98
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, timeout * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
|
|
84
|
-
if ([self
|
|
99
|
+
if (hasListeners && [self canSendEvents]) {
|
|
85
100
|
[self sendEventWithName:@"backgroundTimer.timeout" body:[NSNumber numberWithInt:timeoutId]];
|
|
86
101
|
}
|
|
87
102
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SDK_VERSION","exports"],"sources":["version.ts"],"sourcesContent":["export const SDK_VERSION = '0.2.
|
|
1
|
+
{"version":3,"names":["SDK_VERSION","exports"],"sources":["version.ts"],"sourcesContent":["export const SDK_VERSION = '0.2.1-staging.1';\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.2.
|
|
1
|
+
export const SDK_VERSION = '0.2.1-staging.1';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SDK_VERSION"],"sources":["version.ts"],"sourcesContent":["export const SDK_VERSION = '0.2.
|
|
1
|
+
{"version":3,"names":["SDK_VERSION"],"sources":["version.ts"],"sourcesContent":["export const SDK_VERSION = '0.2.1-staging.1';\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.2.
|
|
1
|
+
export declare const SDK_VERSION = "0.2.1-staging.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/realtimekit-react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-staging.1",
|
|
4
4
|
"description": "Cloudflare RealtimeKit SDK for react native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"author": "Cloudflare",
|
|
@@ -45,9 +45,7 @@
|
|
|
45
45
|
"react-native": "*"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
|
-
"
|
|
49
|
-
"access": "public",
|
|
50
|
-
"tag": "latest"
|
|
48
|
+
"tag": "staging"
|
|
51
49
|
},
|
|
52
50
|
"scripts": {
|
|
53
51
|
"postpublish": "mv package.json.bak package.json"
|