当前位置:   article > 正文

2024 swift IOS扩展键盘打开主应用超级简单

2024 swift IOS扩展键盘打开主应用超级简单

设置url types
在这里插入图片描述
主应用修改info.list

<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLName</key>
			<string>com.MelissaShu.MSImagePick</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>ms</string>
			</array>
		</dict>
	</array>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

键盘infolist

	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>wechat</string>
		<string>weixin</string>
		<string>sinaweibohd</string>
		<string>sinaweibo</string>
		<string>sinaweibosso</string>
		<string>weibosdk</string>
		<string>weibosdk2.5</string>
		<string>openapp.jdmobile</string>
		<string>taobao</string>
		<string>tmall</string>
		<string>ms</string> //自建的应用url 对应主应用其他是打开别的app用的
		<string>alipay</string>
		<string>alipayshare</string>
	</array>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

调起代码

@objc func openURL(_ url: URL) {
    
         return
      }
  
  func openApp(_ urlstring:String) {

         var responder: UIResponder? = self as UIResponder
         let selector = #selector(openURL(_:))
         while responder != nil {
            if responder!.responds(to: selector) && responder != self {
               responder!.perform(selector, with: URL(string: urlstring)!)
               return
            }
            responder = responder?.next
          }
       }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

openApp( “ms://”) 就可以打开主应用了

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/599033
推荐阅读
相关标签
  

闽ICP备14008679号