Closed hernangonzalez closed 11 years ago
Hi Hernan,
Actually that check is already done on - (void)prepareWithActivityItems:(NSArray *)activityItems
and you have to check with the complete URL because previous versions of WhatsApp responds to whatsapp://
but not with send
, abid
or text
params.
Anyways, I'm gonna change this method a little in order to no display the Whatsapp icon on the UIActivityController when no action can be done instance of display a icon that no produce actions, as is happening now.
Thanks!
Hi,
I wanted something handy that would not imply much from the user. I took the idea from your demo project where you have:
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"]]) { ... }
So, that check can be done with the lib:
if ([JBWhatsAppActivity canShareOnWhatsApp]) { ... }
Maybe improving support for older versions would work.
Regards, Hernán.
Hi,
good point, but maybe the best solution is that the UIActivity will be smart enough to not crash if can't open the link, and not worry the user to do that checks.
I just updated the demo project and now you can add JBWhatsAppActivity
always to your UIActivityViewController
and the one only show the WhatsApp button if can open the URL.
WhatsAppMessage *whatsappMsg = [[WhatsAppMessage alloc] initWithMessage:_messageTextField.text forABID:_abidTextField.text];
NSArray *applicationActivities = @[[[JBWhatsAppActivity alloc] init]];
NSArray *excludedActivities = @[UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeMessage];
NSArray *activityItems = @[_messageTextField.text, whatsappMsg];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityViewController.excludedActivityTypes = excludedActivities;
[self presentViewController:activityViewController animated:YES completion:^{}];
How do you see that? Best regards
Yes, much better.I prefer not to present the user with an option he won't be able to use. That's the safest choise for the lib. I would also like not to do anything on my code. Just not to create the objects. Thanks!
Hello, I have added a class method to verify if the activity can take place. Thanks.