The user can share things through email from an UIActivityViewController. When the recipient receives the email, they have a link that they can click to take them to the app. However, currently the link takes them to the app store, which my app is not on yet. How can I change this so that they open the app on their device from the email? I am using the following code right now:
NSString *appName = [NSString stringWithString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]];
NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.com/app/%@",[appName stringByReplacingOccurrencesOfString:@" " withString:@""]]];
I changed my code to the following (Now I am showing all of the actions code, not just the ling):
NSString *shareCaption = captionText.text;
UIImage *shareImage = [UIImage imageWithData:_photo];
NSURL *appURL = [NSURL URLWithString:[NSString stringWithFormat:@"<BR><BR><BR><A HREF=\"http://myApp://\">Open App</A>"]];
NSArray *shareItems = @[shareCaption, shareImage, appURL];
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
activity.excludedActivityTypes = @[];
[self presentViewController:activity animated:YES completion:nil];
However, when I changed the url to this the app crashes and I get the following message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]'
Open App` is a value `NSURL`? – rmaddy Jan 31 '16 at 03:46