首页 > 解决方案 > 如何在whatsapp上发送消息而不使用react-native打开应用程序?

问题描述

有没有办法使用 react-native 在 WhatsApp 上自动发送消息?如果没有,我可以在android上使用桥接吗?

标签: react-nativewhatsapp

解决方案


你可以使用这样的链接:

export const sendWhatsAppMessage = link => {
 if (!isUndefined(link)) {
  Linking.canOpenURL(link)
   .then(supported => {
     if (!supported) {
      Alert.alert(
        'Please install whats app to send direct message'
      );
    } else {
      return Linking.openURL(link);
    }
  })
  .catch(err => console.error('An error occurred', err));
} else {
  console.log('sendWhatsAppMessage -----> ', 'message link is undefined');
 }
};

推荐阅读