【问题标题】:Unable to share text to Whatsapp in iOS 9 [duplicate]无法在 iOS 9 中与 Whatsapp 共享文本 [重复]
【发布时间】:2016-05-11 13:06:21
【问题描述】:

在 iOS 8 及以下版本上与 Whatsapp 共享文本时,此代码运行良好,但在 iOS 9 上共享时,它无法运行。

- (IBAction)btnWhatsApp:(id)sender {
    NSString *msg = shareText;
    NSString *urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];
    NSURL *whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
        [[UIApplication sharedApplication] openURL: whatsappURL];
    }
    else {
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }

    [self.tabBarController.tabBar setHidden:NO];
    [viewShare setHidden:YES];
}

【问题讨论】:

  • 你遇到了什么错误?

标签: ios objective-c swift


【解决方案1】:

iOS 9LSApplicationQueriesSchemes需要任何电话,请确保您在.plist中添加了以下信息:

<key>LSApplicationQueriesSchemes</key>
 <array>
  <string>whatsapp</string>
 </array>

那就试试

【讨论】:

  • 谢谢它的工作......
  • @PPreeti - 很高兴听到这个
【解决方案2】:

如果您为 iOS 9 或更高版本构建,则需要将您的应用将查询的方案列入白名单。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-11
相关资源
最近更新 更多