| 123456789101112131415 |
- import { Linking, Alert } from 'react-native';
- export const handleGoWhatsApp = async () => {
- const phoneWithCountryCode = '8528691382139'; // 不带 "+",如 +60 改成 60(马来西亚)
- const message = 'Hello!';
- const url = `whatsapp://send?phone=${phoneWithCountryCode}&text=${encodeURIComponent(message)}`;
- const supported = await Linking.canOpenURL(url);
- if (supported) {
- await Linking.openURL(url);
- } else {
- Alert.alert('WhatsApp 未安裝', '請先安裝 WhatsApp 應用');
- }
- };
|