Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React Native: Linking.openUrl throwing "Possible Unhandled Promise Rejection (id: 0): Error: Unable to open URL:"

$
0
0

I am trying to create a Audio/Video Calling app using React Native. There's a screen in the app where calling happens using WebRTC. Let's call it 'Call' screen. TO show calling notification I am using the package react-native-callkeep. Once a user picks up the call, I'm taking him directly to the 'Call' screen. Everything works fine except when I'm trying to take the user to the 'Call' screen.

Here's how I'm doing it:

Inside my AppDelegate.m I have this

- (BOOL)application:(UIApplication *)application   openURL:(NSURL *)url   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{  return [RCTLinkingManager application:application openURL:url options:options];}- (BOOL)application:(UIApplication *)applicationcontinueUserActivity:(NSUserActivity *)userActivity  restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler{  return [RNCallKeep application:application           continueUserActivity:userActivity             restorationHandler:restorationHandler];}

Inside the index.js, I'm calling initCalling before registering the app like this:

...initCalling();AppRegistry.registerComponent(appName, () => App);

And Here's what initCalling does

const initCalling = () => {  const options = {    ios: {      appName: 'MyApp',      includesCallsInRecents: false,      imageName: 'notification_icon',      supportsVideo: true,    },    android: {      alertTitle: 'Permissions required',      alertDescription: 'This application needs to access your Calling Service',      cancelButton: 'Cancel',      okButton: 'ok',      imageName: 'notification_icon',    }  };  RNCallKeep.setup(options);  function checkCallNotification(message) {    if (!message.data.callType) {      return;    }    const { threadId, messageKey } = message.data;    RNCallKeep.displayIncomingCall(      message.data.channelId,      message.data.title,      message.data.title,'number',      message.data.callType === 'video',    );    RNCallKeep.addEventListener('answerCall', async () => {      RNCallKeep.removeEventListener('endCall');      RNCallKeep.endAllCalls();      Linking.openURL(message.data.deeplink);      RNCallKeep.removeEventListener('answerCall');    });    RNCallKeep.addEventListener('endCall', () => {      RNCallKeep.endAllCalls();      RNCallKeep.removeEventListener('endCall');    });  }  messaging().setBackgroundMessageHandler(async (remoteMessage) => {    checkCallNotification(remoteMessage);  });  messaging().onMessage(async (remoteMessage) => {    checkCallNotification(remoteMessage);  });}

When a notification arrives, the call keep starts showing the call screen. Once user picks up the call, Im trying to take him to the 'Call' screen but instead I'm getting this

index.bundle?platfor…&minify=false:41712 Possible Unhandled Promise Rejection (id: 0):Error: Unable to open URL: myapp://callError: Unable to open URL: myapp://call

on debugging I can see the line Linking.openURL(message.data.deeplink); is failing even though the url is correct. And this is happening only in iOS. On Android things are working perfect. Can someone please help me know what I'm doing wrong ? Thanks !


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>