I am new to flex mobile app development, I wanna share a text via whatsapp
. Here is some code.But its not working.
navigateToURL(new URLRequest("whatsapp://send?text=Hello how r u???" )
Can u please help me. Thanks in advance.
I am new to flex mobile app development, I wanna share a text via whatsapp
. Here is some code.But its not working.
navigateToURL(new URLRequest("whatsapp://send?text=Hello how r u???" )
Can u please help me. Thanks in advance.
Try this code. Should work perfectly.
-(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);
}