rns-nativecall 0.1.9 → 0.2.2

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.
Files changed (2) hide show
  1. package/ios/CallModule.m +30 -10
  2. package/package.json +1 -1
package/ios/CallModule.m CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  RCT_EXPORT_MODULE();
6
6
 
7
- // Crucial: This keeps the module alive and on the main thread
8
7
  + (BOOL)requiresMainQueueSetup {
9
8
  return YES;
10
9
  }
@@ -22,10 +21,9 @@ RCT_EXPORT_MODULE();
22
21
  config.supportsVideo = YES;
23
22
  config.maximumCallGroups = 1;
24
23
  config.maximumCallsPerCallGroup = 1;
24
+ config.includesCallsInRecents = NO;
25
25
  config.supportedHandleTypes = [NSSet setWithObject:@(CXHandleTypeGeneric)];
26
- // Add this to prevent system confusion
27
- config.ringtoneSound = @"Ringtone.caf";
28
-
26
+
29
27
  self.provider = [[CXProvider alloc] initWithConfiguration:config];
30
28
  [self.provider setDelegate:self queue:nil];
31
29
  }
@@ -46,13 +44,12 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
46
44
 
47
45
  self.currentCallUUID = uuid;
48
46
 
49
- // 1. CONFIGURE AUDIO SESSION FIRST (Prevents Auto-Drop)
47
+ // 1. CONFIGURE AUDIO SESSION (Pre-warm)
50
48
  AVAudioSession *session = [AVAudioSession sharedInstance];
51
- NSError *error = nil;
52
49
  [session setCategory:AVAudioSessionCategoryPlayAndRecord
53
50
  mode:AVAudioSessionModeVoiceChat
54
- options:AVAudioSessionCategoryOptionAllowBluetooth
55
- error:&error];
51
+ options:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker
52
+ error:nil];
56
53
 
57
54
  CXCallUpdate *update = [[CXCallUpdate alloc] init];
58
55
  update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:name];
@@ -67,13 +64,37 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
67
64
  }];
68
65
  }
69
66
 
67
+ RCT_EXPORT_METHOD(endNativeCall:(NSString *)uuidString)
68
+ {
69
+ NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
70
+ if (!uuid) return;
71
+
72
+ [self.provider reportCallWithUUID:uuid
73
+ endedAtDate:[NSDate date]
74
+ reason:CXCallEndedReasonRemoteEnded];
75
+ self.currentCallUUID = nil;
76
+ }
77
+
78
+ RCT_EXPORT_METHOD(getInitialCallData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
79
+ resolve([NSNull null]);
80
+ }
81
+
82
+ RCT_EXPORT_METHOD(checkTelecomPermissions:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
83
+ resolve(@YES);
84
+ }
85
+
70
86
  // MARK: - CXProviderDelegate
71
87
 
72
88
  - (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
73
- // 2. ACTIVATE AUDIO SESSION (Crucial for CallKit)
89
+ // 1. Activate Audio Session
90
+ // This transition tells iOS the app is now the active audio owner, which triggers the foregrounding
74
91
  [[AVAudioSession sharedInstance] setActive:YES error:nil];
75
92
 
93
+ // 2. Fulfill the action
76
94
  [action fulfill];
95
+
96
+ // 3. Notify JavaScript
97
+ // Once JS receives this, the navigationRef in App.js handles the UI transition
77
98
  [self sendEventWithName:@"onCallAccepted" body:@{@"callUuid": [action.callUUID.UUIDString lowercaseString]}];
78
99
  }
79
100
 
@@ -84,7 +105,6 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
84
105
  }
85
106
 
86
107
  - (void)providerDidReset:(CXProvider *)provider {
87
- // Stop all audio if provider resets
88
108
  [[AVAudioSession sharedInstance] setActive:NO error:nil];
89
109
  }
90
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.1.9",
3
+ "version": "0.2.2",
4
4
  "description": "RNS nativecall component with native Android/iOS for handling native call ui, when app is not open or open.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",