我正在使用以下代码共享以通过UIActivityViewController共享一些文本。
NSString *appUrlAppStore = @"https://itunes.apple.com/app/imdb-movies-tv/id342792525";
NSString *appUrlPlayStore = @"https://play.google.com/store/apps/details?id=com.imdb.mobile";
NSString *textToShare = [NSString stringWithFormat:@"Hey, this is an Awesome app and you can get this from App Store : %@ Play Store : %@", appUrlAppStore ,appUrlPlayStore];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[textToShare] applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:YES completion:nil];
现在问题是哪个链接是第一个(就像在上面的App Store中一样)什么应用程序获取该链接的缩略图
我想要的是,如果该设备是ios,它应该选择appStore和Android,它应该选择Play商店。
我确实知道这是WhatsApp的默认行为,但是我的问题的解决方案是什么。或者,如果大多数应用程序的行为都是这样,我想我的用户也不会介意。
或者是否有任何我不想要的关键事项。
任何评论都表示赞赏。
答案 0 :(得分:1)
使用可以使用branch.io为iOS生成一个链接,android也可以跟踪链接。 Branch.io提供与推荐系统的深层链接,共享链接,邀请和营销链接以及完整的归因和分析。您可以参考branch.io进行SDK集成,或者更简单一点,您可以参考branch.io Git repo进行集成。
用此代码替换您的UIActivityViewController。
BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"user_id"];
branchUniversalObject.title = @"Hey, this is an Awesome app and you can get this from App Store";
branchUniversalObject.contentDescription =[NSString stringWithFormat:@"%@ %@ %@",@"Your friend",user_name,@"has invited you to download awesome App"];
branchUniversalObject.imageUrl = @"APP_Image_url";
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"share";
linkProperties.channel = @"WhatsApp";
[branchUniversalObject showShareSheetWithLinkProperties:linkProperties
andShareText:@"Super amazing App I want to share!"
fromViewController:self
andCallback:^{
NSLog(@"finished sharing link");
}];