diff --git a/RNCallKeep.podspec b/RNCallKeep.podspec index 821d4a50..be08dc18 100644 --- a/RNCallKeep.podspec +++ b/RNCallKeep.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |s| s.requires_arc = true s.platform = :ios, "8.0" s.source_files = "ios/RNCallKeep/*.{h,m}" - s.dependency 'React/Core' + s.dependency 'React-Core' end diff --git a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java index 15b9cce2..aa905b34 100644 --- a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java +++ b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java @@ -214,7 +214,7 @@ public void endAllCalls() { @ReactMethod public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promise promise) { - Activity currentActivity = this.getCurrentActivity(); + Activity currentActivity = getCurrentActivity(); if (!isConnectionServiceAvailable()) { promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "ConnectionService not available for this version of Android."); @@ -464,7 +464,7 @@ private String getApplicationName(Context appContext) { } private Boolean hasPermissions() { - Activity currentActivity = this.getCurrentActivity(); + Activity currentActivity = getCurrentActivity(); boolean hasPermissions = true; for (String permission : permissions) { diff --git a/example/.snyk b/example/.snyk new file mode 100644 index 00000000..8692167f --- /dev/null +++ b/example/.snyk @@ -0,0 +1,8 @@ +# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. +version: v1.22.1 +ignore: {} +# patches apply the minimum changes required to fix a vulnerability +patch: + SNYK-JS-LODASH-567746: + - react-native > @react-native-community/cli > metro > metro-config > metro > metro-react-native-babel-preset > @babel/plugin-transform-exponentiation-operator > @babel/helper-builder-binary-assignment-operator-visitor > @babel/helper-explode-assignable-expression > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash: + patched: '2022-04-08T03:12:55.467Z' diff --git a/example/package.json b/example/package.json index e3263218..7d4ed728 100644 --- a/example/package.json +++ b/example/package.json @@ -3,7 +3,9 @@ "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios", - "web": "expo start --web" + "web": "expo start --web", + "prepare": "yarn run snyk-protect", + "snyk-protect": "snyk-protect" }, "dependencies": { "expo": "^34.0.1", @@ -17,10 +19,12 @@ "react-native-reanimated": "~1.1.0", "react-native-unimodules": "~0.5.2", "react-native-web": "^0.11.4", - "uuid": "^3.3.2" + "uuid": "^3.3.2", + "@snyk/protect": "latest" }, "devDependencies": { "babel-preset-expo": "^6.0.0" }, - "private": true + "private": true, + "snyk": true } diff --git a/example/yarn.lock b/example/yarn.lock index db370bdb..a28a6d60 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -897,6 +897,11 @@ xcode "^2.0.0" xmldoc "^0.4.0" +"@snyk/protect@^1.898.0": + version "1.898.0" + resolved "https://registry.yarnpkg.com/@snyk/protect/-/protect-1.898.0.tgz#2a10cf07f019064e4c9e5ea172fc5a0a72bc5196" + integrity sha512-v4G6UD3hrLhV2DeBnmNg927PyDkKGAN0m4xJgi75dtgbT2dCXB45sjQNd0h+eSMidbwoa+z+m7NOaXMcoixp4Q== + "@types/fbemitter@^2.0.32": version "2.0.32" resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c" diff --git a/index.d.ts b/index.d.ts index 65a19e94..f735ddb4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -55,6 +55,10 @@ export default class RNCallKeep { } + static async hasRequiredPermissions(options: IOptions): Promise { + + } + static displayIncomingCall( uuid: string, handle: string, @@ -159,6 +163,10 @@ export default class RNCallKeep { } + static checkPhoneAccountPermission(): Promise { + + } + /** * @description setAvailable method is available only on Android. */ diff --git a/index.js b/index.js index f4613c2d..03eb5740 100644 --- a/index.js +++ b/index.js @@ -43,6 +43,14 @@ class RNCallKeep { return; }; + + hasRequiredPermissions = async (options) => { + if(isIOS) { + return true; + } + RNCallKeepModule.setup(options); + return await this.hasPhoneAccount(); + } displayIncomingCall = (uuid, handle, localizedCallerName, handleType = 'number', hasVideo = false) => { if (!isIOS) { @@ -124,6 +132,9 @@ class RNCallKeep { ? RNCallKeepModule.checkSpeaker() : Promise.reject('RNCallKeep.checkSpeaker was called from unsupported OS'); + + checkPhoneAccountPermission = async (options) => await RNCallKeepModule.checkPhoneAccountPermission(options.additionalPermissions || []); + setAvailable = (state) => { if (isIOS) { return; diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 02432a33..d0142e5a 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -466,8 +466,15 @@ + (BOOL)application:(UIApplication *)application // iOS 13 returns an INStartCallIntent userActivity type if (@available(iOS 13, *)) { INStartCallIntent *intent = (INStartCallIntent*)interaction.intent; - isAudioCall = intent.callCapability == INCallCapabilityAudioCall; - isVideoCall = intent.callCapability == INCallCapabilityVideoCall; + // isAudioCall = intent.callCapability == INCallCapabilityAudioCall; + // isVideoCall = intent.callCapability == INCallCapabilityVideoCall; + if ([intent respondsToSelector:@selector(callCapability)]) { + isAudioCall = intent.callCapability == INCallCapabilityAudioCall; + isVideoCall = intent.callCapability == INCallCapabilityVideoCall; + } else { + isAudioCall = [userActivity.activityType isEqualToString:INStartAudioCallIntentIdentifier]; + isVideoCall = [userActivity.activityType isEqualToString:INStartVideoCallIntentIdentifier]; + } } else { isAudioCall = [userActivity.activityType isEqualToString:INStartAudioCallIntentIdentifier]; isVideoCall = [userActivity.activityType isEqualToString:INStartVideoCallIntentIdentifier]; @@ -566,7 +573,7 @@ - (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAct NSLog(@"[RNCallKeep][CXProviderDelegate][provider:performAnswerCallAction]"); #endif [self configureAudioSession]; - [self sendEventWithName:RNCallKeepPerformAnswerCallAction body:@{ @"callUUID": [action.callUUID.UUIDString lowercaseString] }]; + [self sendEventWithName:RNCallKeepPerformAnswerCallAction body:@{ @"callUUID": [action.callUUID.UUIDString lowercaseString], @"isLocked": [[UIApplication sharedApplication] isProtectedDataAvailable] ? @"false" : @"true" }]; [action fulfill]; }