【问题标题】:Sending text via whatsapp is not working通过whatsapp发送文本不起作用
【发布时间】:2026-01-21 01:25:01
【问题描述】:

我是 flex 移动应用程序开发的新手,我想通过 whatsapp 分享一个文本。这是一些代码。但它不起作用。

navigateToURL(new URLRequest("whatsapp://send?text=Hello how r u???" )

你能帮帮我吗? 提前致谢。

【问题讨论】:

  • 在这里找到任何解决方案??
  • 不。通过邮件联系 whatsapp 团队后,我知道这是不可能的,因为 whatapp 不提供任何 3rd 方 API。如果您有任何解决方案,请在此处评论@Yossi
  • 其实我明白了。看看我下面的答案。

标签: actionscript-3 apache-flex flexbuilder whatsapp


【解决方案1】:

试试这个代码。应该可以完美运行。

-(void)whatsapp{
        NSString *massage = [self stringByEncodingString:@"Your massage"];
        NSString *urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",massage];
        NSURL *whatsappURL = [NSURL URLWithString:urlWhats];
        if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
             [[UIApplication sharedApplication] openURL: whatsappURL];
        } else {
             UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has to have WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
             [alert show];
        }
}

-(NSString *)stringByEncodingString:(NSString *)string{
        CFStringRef encodedString = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)string, NULL,
                                                                    (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8);
        return CFBridgingRelease(encodedString);
}

【讨论】:

    最近更新 更多