我正在开发一个应用程序,我在其中使用一些网址分享事件图像 共享事件图像时,我正在使用此内容:=
“嘿!我刚刚看到”Venue Name“通过XXXX App获得了”活动名称“!我们 应该看看。 https://app.com/site/redirectlink?event_id=%@“
现在我可以将此“https://app.com/site/redirectlink?event_id=%@”链接到“此处”超链接吗?
我通过“UIActivityViewController”分享这些内容。 实际上,此URL(https://app.com/site/redirectlink?event_id=%@)稍后用于深层链接,当用户单击此链接时,它将根据event_id重定向到特定事件。 而不是我想在这里使用的整个URL(作为超链接)。
答案 0 :(得分:1)
可能会帮助你这样做..
NSString *url=@"https://app.com/site/redirectlink?event_id=%@";
NSString * title =[NSString stringWithFormat:@"Hey! I just saw \"Venue Name\" is having \"Event Name\" through the XXXX App! We should check it out <html> <body> <a href = '%@'>here</a> </body> </html>",url];
NSArray* dataToShare = @[title];
UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeAirDrop];
[self presentViewController:activityViewController animated:YES completion:^{}];
答案 1 :(得分:0)
您可能需要深层链接网址:projectName://myapp?event_id=12345
添加 info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.erimkurt.projectName</string>
<key>CFBundleURLSchemes</key>
<array>
<string>projectName</string>
</array>
</dict>
</array>
添加 appdelegete.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"Calling Application Bundle ID: %@", sourceApplication);
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
if (!url) { return NO; }
UIAlertView *alertView;
alertView = [[UIAlertView alloc] initWithTitle:@"Launch by URL" message:@"This app was launched from a URL" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
NSString *urlString = [url absoluteString];
[[NSUserDefaults standardUserDefaults] setObject:urlString forKey:@"url"];
[[NSUserDefaults standardUserDefaults] synchronize];
return YES;
}
添加 viewController.m
NSString *url = [[NSUserDefaults standardUserDefaults] objectForKey:@"url"];
NSLog(@"MYAPPURL: %@",url);