如何为iOS和Android配置WhatsApp共享按钮?

时间:2015-07-04 11:49:56

标签: javascript php ios objective-c whatsapp

问题是Android和iOS有不同的方案URL。

Android

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

iOS - Objective-C

NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
    [[UIApplication sharedApplication] openURL: whatsappURL];
}

我按如下方式定义设备类型:

<?php
$iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
if( $iPod || $iPhone || $iPad ) {
    // ???
} else if( $Android ) {
   echo '<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>';
}
?>

如果网站使用php和javascript(jquery),请告诉我如何使用Objective-C文档中显示的代码? 谢谢!

0 个答案:

没有答案