gpt4 book ai didi

ios - 空投:使自定义 URL 方案对收件人来说不那么难看

转载 作者:行者123 更新时间:2023-11-28 22:21:42 25 4
gpt4 key购买 nike

我正在使用 Airdrop 发送自定义 URL,使我的应用在其他设备上打开并显示相关信息。

它工作正常,但在接收设备上看起来真的很难看,因为他们收到一条消息,其中引用了正在发送的 URL,例如 schemename://123456。有什么方法可以使消息看起来更好,或者让接收设备告诉您它想在哪个应用程序中打开信息,而不是显示神秘的 URL?

最佳答案

制作一个与 UIActivityItemSource 确认的自定义对象

 @interface LAAirDropCustomUrl : NSObject <UIActivityItemSource>

@property (strong, nonatomic) NSURL *url;
@property (strong, nonatomic) UIImage *productImage;
- (id)initWithUrl:(NSURL *)url;


@end



@implementation LAAirDropCustomUrl

- (id)initWithUrl:(NSURL *)url {
if (self = [super init]) {
_url = url;
}
return self;
}

#pragma mark - UIActivityItemSource

- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
//Because the URL is already set it can be the placeholder. The API will use this to determine that an object of class type NSURL will be sent.
return self.url;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
//Return the URL being used. This URL has a custom scheme (see ReadMe.txt and Info.plist for more information about registering a custom URL scheme).
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
return nil;
} else {
if ([activityType isEqualToString:UIActivityTypeAirDrop]) {
return self.url;
}
}
return nil;
}

- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size
{
//Add image to improve the look of the alert received on the other side, make sure it is scaled to the suggested size.

return self.productImage;
}

关于ios - 空投:使自定义 URL 方案对收件人来说不那么难看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20216100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com