zoukankan      html  css  js  c++  java
  • iOS利用剪切板在app中传递信息

    利用iOS剪切板在app中传递信息

    App1 中添加URLSchemes   app1

    App2 中国添加URLSchemes   app2

    App1中进入app2:

    UIApplication.shared.open(URL(string: "App2://getData")!, options: [:], completionHandler: nil)

    app2中在appadelegate中

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

            if url.absoluteString.hasSuffix("getData"){

                    let pasteboard = UIPasteboard(name: .init("KmyPasteboard"), create: true)

                    pasteboard!.string = “需要传的数据信息”

                }

                

                if #available(iOS 10.0, *) {

                    UIApplication.shared.open(URL(string: "App1://getData")!, options: [:], completionHandler: nil)//返回app1

                } else {

                    // Fallback on earlier versions

                }

            }

    return true

    }

    返回进入app1后

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

            if url.absoluteString.hasSuffix("getData") {

                let pasteboard = UIPasteboard(name: .init("KmyPasteboard"), create: true)

                let jsonStr = pasteboard!.string

                pasteboard!.string = “”//清空剪切板

                NotificationCenter.default.post(name: NSNotification.Name("Active"), object: jsonStr)

            }

            return true

        }

  • 相关阅读:
    C# 实现 JAVA AES加密解密(转他人)
    转 Java、C#双语版配套AES加解密示例
    开发工具资料
    WebApi返回Json格式
    【转】NuGet.org 无法访问的解决方法
    使用Senparc.Weixin.WxOpen开发高可用的微信小程序
    WebApi资料
    WinForm资料
    Winform开发框架之终极应用
    Winform开发中另一种样式的OutLookBar工具条
  • 原文地址:https://www.cnblogs.com/duzhaoquan/p/11009042.html
Copyright © 2011-2022 走看看