WhatsApp共享不工作(相同的代码正在另一个项目中工作)

以下是我在WhatsApp上共享文本的方法

NSString *globalString; NSString *myURl = [NSString stringWithFormat:@"http://www.mywebq8.com/mobile/newsdetails.aspx?id=%@", [global getstrProDetails]]; globalString =[NSString stringWithFormat: @"%@ للمزيد \n\n%@",[global getstrPagetitle], myURl]; NSLog(@"globalString===%@", globalString); NSString * msg = globalString; 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 *mAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Your device doesn't have WhatsApp." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [mAl show]; } 

下面是我有NSLog的输出。

 حاول الانتحار فألقى بنفسه بين أسود.. وخرج حياً للمزيد http://www.mywebq8.com/mobile/newsdetails.aspx?id=22455 

当我点击WhatsApp的图标,它的开放WhatsApp但消息不显示在显示…它只是显示空白。

任何想法,为什么这是工作?

注意:相同的代码正在工作是我的另一个项目,在2016年5月9日更新。


编辑1

即使我在下面尝试它不工作

 This is test text http://www.mywebq8.com/mobile/newsdetails.aspx?id=22455 

这是你的解决scheme。 问题出在URL编码。 请在下面find我的testing解决scheme

 NSString *globalString; NSString *myURl = [NSString stringWithFormat:@"http://www.mywebq8.com/mobile/newsdetails.aspx?id=%@", [global getstrProDetails]]; myURl = [myURl stringByReplacingOccurrencesOfString:@":" withString:@"%3A"]; myURl = [myURl stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"]; myURl = [myURl stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"]; myURl = [myURl stringByReplacingOccurrencesOfString:@"," withString:@"%2C"]; myURl = [myURl stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"]; myURl = [myURl stringByReplacingOccurrencesOfString:@"&" withString:@"%26"]; globalString =[NSString stringWithFormat: @"%@ للمزيد \n\n",[global getstrPagetitle]]; NSLog(@"globalString===%@", globalString); NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@", globalString ]; NSString *msg = [NSString stringWithFormat:@"%@%@",[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],myURl]; NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: [NSURL URLWithString:msg]]; } else { UIAlertView *mAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Your device doesn't have WhatsApp." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [mAl show]; } 

希望这可以帮助!。

让我知道如果你发现任何困难。