获取全局的剪切板内容并作出提示
在这个方法中去拦截剪贴版的内容并做判读
- (void)applicationDidBecomeActive:(UIApplication *)application
对获取到内容的处理
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
if ([pasteBoard.string hasPrefix:@"http://"] ||
[pasteBoard.string hasPrefix:@"https://"]) {
UIAlertController *alertVc = [UIAlertController
alertControllerWithTitle:@"要打开其中的链接吗?"
message:nil
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *actionConfirm =
[UIAlertAction actionWithTitle:@"打开"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
NSLog(@"打开链接");//打开链接要做的跳转操作
}];
UIAlertAction *actionRefuse =
[UIAlertAction actionWithTitle:@"忽略"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
NSLog(@"忽略");// 忽略的跳转操作
pasteboard.string = @"";
}];
[alertVc addAction:actionConfirm];
[alertVc addAction:actionRefuse];
[self.window.rootViewController presentViewController:alertVc
animated:YES
completion:nil];
}