问题是Android和iOS有不同的方案URL。
<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文档中显示的代码? 谢谢!