我使用以下代码来通过 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 的默认行为,但是我的问题的解决方案是什么。或者,如果大多数应用确实如此,我想我的用户也不会介意。
或者我遗漏了什么关键的东西。
任何意见表示赞赏。
最佳答案
使用可以使用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");
}];
关于ios - 在 Whats App 上分享 App Store 和 Play 商店链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41911057/