【发布时间】:2013-05-28 07:25:18
【问题描述】:
对于 iPhone 应用程序,是否可以在产品上添加 Whatsapp 链接?一旦链接它会通过whatsapp向我的手机号码发送一条消息。请指教。
【问题讨论】:
标签: iphone ios objective-c message whatsapp
对于 iPhone 应用程序,是否可以在产品上添加 Whatsapp 链接?一旦链接它会通过whatsapp向我的手机号码发送一条消息。请指教。
【问题讨论】:
标签: iphone ios objective-c message whatsapp
您可以使用 tafh 建议的自定义方法,或者作为 iOS 应用程序开发人员,我建议您使用文档交互控制器,初始化 UIDocumentInteractionController。这些都可以帮助您管理交互。查看下面的链接了解更多信息。
(UIDocumentInteractionController *) setupControllerWithURL: (NSURL) fileURL
usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController =
[UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
【讨论】:
notification = @"Your Daily Inspiration by the ";
notification = [notification stringByAppendingString:@"\n"];
notification = [notification stringByAppendingString:textview.text];
NSString *whats=notification;
NSString *baseURL = [NSString stringWithFormat:@"whatsapp://send?text=%@",whats];
NSURL *url = [NSURL URLWithString:[baseURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: url]) {
[[UIApplication sharedApplication] openURL: url];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry"
message:@"You can't send a thought on Whatsapp"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
使用此代码我在 whatsapp 上发送以下字符串
【讨论】:
我不确定你的意思,但也许这就是你要找的:http://www.whatsapp.com/faq/en/iphone/23559013
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
【讨论】:
【讨论】: