使用WhatsApp调用反应Native Linking.canOpenURL()

Mar*_*ães 5 javascript deep-linking whatsapp react-native

我正在尝试创建一个链接以从我的本机应用程序开始在whatsapp上进行对话,但是方法Linking.canOpenURL()始终将false调整为...

我的代码如下:

const url = `whatsapp://send?phone=${celNumber}`;
Linking.canOpenURL(url).then(supported => {
    if (supported) {
        Linking.openURL(url);
    } else {
        Alert.alert(
            'Alert',
            'WhatsApp is not installed',
        )
    }
});
Run Code Online (Sandbox Code Playgroud)

如果我尝试将其他网址设为tel:${celNumber}true,那么我认为whatsapp网址和canOpenURL()存在一些问题,因为whatsapp网址可与方法Linking.openURL()一起使用...

Sin*_*kka 2

我猜您使用的是 iOS?\n那么您必须在 Info.plist 文件 LSApplicationQueriesSchemes 中声明 URL\xe2\x80\x99s 方案 \'whatsapp\'。

\n\n

iOS9:canOpenURL 对于 WhatApp 的 url 方案返回 false

\n\n

https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl

\n