whatsapp

论坛 期权论坛 脚本     
匿名技术用户   2021-1-2 18:42   83   0

//文字分享

NSString *msg = @"您好";

NSString *url = [NSString stringWithFormat:@"whatsapp://send?text=%@", [msg stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];

NSURL *whatsappURL = [NSURL URLWithString: url];

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){

// [[UIApplication sharedApplication] openURL: whatsappURL];

[[UIApplication sharedApplication] openURL:whatsappURL options:@{} completionHandler:nil];

NSLog(@"fff");

// 图片分享

// UIImage * iconImage = [UIImage imageNamed:@"icon.png"];

//

//

// [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];

//

//

// _documentInteractionController = [[UIDocumentInteractionController alloc]init];

// _documentInteractionController.UTI = @"net.whatsapp.image";

//

//

// _documentInteractionController.delegate = self;

//

//

// [_documentInteractionController presentOpenInMenuFromRect:self.view.bounds inView:self.view animated: YES];

// }

} else {

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alert show];

}

需要注意的plist文件中也需要加入白名单

LSApplicationQueriesSchemes Array类型

whatsapp

转载于:https://www.cnblogs.com/hangman/p/6911767.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP