在 whats app 上分享 App Store 和 Play 商店链接

Share on whats app both App Store and Play store links

我正在使用以下代码通过 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];

现在的问题是哪个 link 是第一个(就像上面的 App Store 中的那个)什么应用程序占用了那个 link

的缩略图

我想要的是,如果设备是 ios 设备,它应该选择 appStore 设备,而 Android 它应该选择 Play 商店设备。

我知道这是 WhatsApp 的默认行为,但我的问题的解决方案是什么。或者,如果大多数应用确实如此,我想我的用户也不会介意。

或者我遗漏了什么关键的东西。

如有任何意见,我们将不胜感激。

使用可以使用branch.io to generate one link for iOS and android also can track links. Branch.io provides deep links with referral systems, sharing links, invites and marketing links with full attribution and analytics. You can refer branch.io for SDK integration or for more simple you can refer 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");
                                        }];