React native send a message to specific whatsapp Number

前端 未结 3 2126
野的像风
野的像风 2021-02-02 11:13

I\'m trying to send a text message to a WhatsApp contact from a react-native apps , i found that i can do it through Linking

Linking.openURL(\'whatsapp://send?t         


        
3条回答
  •  醉话见心
    2021-02-02 11:17

    You can use this method to send whatsApp message direct to a number.

    Example link: https://wa.me/919234567812?text=%7B0%7D+Balaji+CTest

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

提交回复
热议问题