File tree Expand file tree Collapse file tree 7 files changed +25
-13
lines changed
android/src/main/java/com/callingx
react-native-sdk/src/utils/StreamVideoRN Expand file tree Collapse file tree 7 files changed +25
-13
lines changed Original file line number Diff line number Diff line change 1+ package com.callingx
2+
13import android.content.Context
24import android.media.RingtoneManager
35import android.net.Uri
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import androidx.core.graphics.drawable.IconCompat
1414import com.callingx.CallService
1515import com.callingx.CallingxModule
1616import com.callingx.R
17+ import com.callingx.ResourceUtils
1718import com.callingx.getDisconnectCauseString
1819import com.callingx.model.Call
1920
Original file line number Diff line number Diff line change @@ -44,11 +44,13 @@ + (CXProviderConfiguration *)getProviderConfiguration:(NSDictionary *)settings {
4444 if (settings[@" maximumCallsPerCallGroup" ]) {
4545 providerConfiguration.maximumCallsPerCallGroup = [settings[@" maximumCallsPerCallGroup" ] integerValue ];
4646 }
47- if (settings[@" imageName" ]) {
48- providerConfiguration.iconTemplateImageData = UIImagePNGRepresentation ([UIImage imageNamed: settings[@" imageName" ]]);
47+ NSString *imageName = settings[@" imageName" ];
48+ if ([imageName isKindOfClass: [NSString class ]] && imageName.length > 0 ) {
49+ providerConfiguration.iconTemplateImageData = UIImagePNGRepresentation ([UIImage imageNamed: imageName]);
4950 }
50- if (settings[@" ringtoneSound" ]) {
51- providerConfiguration.ringtoneSound = settings[@" ringtoneSound" ];
51+ NSString *ringtoneSound = settings[@" ringtoneSound" ];
52+ if ([ringtoneSound isKindOfClass: [NSString class ]] && ringtoneSound.length > 0 ) {
53+ providerConfiguration.ringtoneSound = ringtoneSound;
5254 }
5355 if (@available (iOS 11.0 , *)) {
5456 if (settings[@" includesCallsInRecents" ]) {
Original file line number Diff line number Diff line change @@ -81,6 +81,17 @@ class CallingxModule implements ICallingxModule {
8181
8282 registerHeadlessTask ( ) ;
8383 }
84+
85+ //by default we will request permissions on setup call
86+ if ( options . enableAutoPermissions ?? true ) {
87+ this . requestPermissions ( )
88+ . then ( ( result ) => {
89+ console . log ( 'Permissions result:' , result ) ;
90+ } )
91+ . catch ( ( error ) => {
92+ console . error ( 'Error requesting permissions:' , error ) ;
93+ } ) ;
94+ }
8495 }
8596
8697 async requestPermissions ( ) : Promise < PermissionsResult > {
Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ export type iOSOptions = {
6666 maximumCallsPerCallGroup ?: number ;
6767 maximumCallGroups ?: number ;
6868 handleType ?: string ; //'generic' | 'number' | 'phone' | 'email';
69- sound ?: string | null ;
70- imageName ?: string | null ;
69+ sound ?: string ;
70+ imageName ?: string ;
7171 callsHistory ?: boolean ;
7272 setupAudioSession ?: boolean ;
7373} ;
@@ -95,6 +95,7 @@ export type Options = {
9595 ios ?: iOSOptions ;
9696 android : AndroidOptions & NotificationTransformers ;
9797 enableOutcomingCalls ?: boolean ;
98+ enableAutoPermissions ?: boolean ;
9899} ;
99100
100101export type InfoDisplayOptions = {
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ export const defaultiOSOptions: Required<iOSOptions> = {
1212 maximumCallsPerCallGroup : 1 ,
1313 maximumCallGroups : 1 ,
1414 handleType : 'generic' ,
15- sound : null ,
16- imageName : null ,
15+ sound : '' ,
16+ imageName : '' ,
1717 callsHistory : false ,
1818 setupAudioSession : true ,
1919} ;
Original file line number Diff line number Diff line change @@ -133,11 +133,6 @@ export class StreamVideoRN {
133133 static setupCallingExp ( options : CallingxOptions ) {
134134 const callingx = getCallingxLib ( ) ;
135135 callingx . setup ( options ) ;
136- callingx . checkPermissions ( ) . catch ( ( error ) => {
137- videoLoggerSystem
138- . getLogger ( 'setupCallingExp' )
139- . error ( 'failed to check permissions' , error ) ;
140- } ) ;
141136 }
142137
143138 static getConfig ( ) {
You can’t perform that action at this time.
0 commit comments