Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义URL方案错误:不允许此应用查询方案_Ios_Swift_Communication Protocol - Fatal编程技术网

Ios 自定义URL方案错误:不允许此应用查询方案

Ios 自定义URL方案错误:不允许此应用查询方案,ios,swift,communication-protocol,Ios,Swift,Communication Protocol,我有两个应用程序,一个客户端和一个服务器。我正在尝试使用URL方案在ios应用程序之间进行应用程序间通信 (我已将此作为指导方针) 这是客户端的plist <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleExecutable</key>

我有两个应用程序,一个客户端和一个服务器。我正在尝试使用URL方案在ios应用程序之间进行应用程序间通信

(我已将此作为指导方针)

这是客户端的plist

<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>CFBundleURLName</key>
            <string>com.test.serverendapp</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>serverendapp</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>com.test.serverendapp</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>
服务器端

普利斯特

<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>CFBundleURLName</key>
            <string>com.test.clientendapp</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>clientendapp</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>com.test.clientendapp</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>
我从他们中得到的只是

-canOpenURL:URL:“com.test.clientEndApp://provideInfo?username='Debanjan'”失败-错误: “不允许此应用查询scheme com.test.clientendapp”

-canOpenURL:URL:“com.test.serverEndApp://requestInfo?userID='22'”失败-错误:“此应用 不允许查询方案com.test.serverendapp“

我已经遵循了所有的步骤,但我仍在这个常规中。帮助我认识到我做错了什么


我在iPhone 8 iOS 12.2模拟器上运行它,在xcode 12.2上运行它,如果您注册,则以相反的方式运行:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.test.clientEndApp</string>
</array>

您的
LSApplicationQueriesSchemes
中缺少了一个
com.test.
,因此,感谢@Lu\ux指出了我的错误

要点: 1.客户端应用程序将具有服务器应用程序的方案,反之亦然
2.LS应该有一个完整的名称,没有这样的com.test或nots,我只是这么做了。它仍然给我错误。请检查更新的plists。你做了什么?您仍然调用与您注册的方案不同的url:
com.test.clientEndApp
clientEndApp
之间存在差异。我更改了您提到的客户端和服务器应用程序的url方案。客户端应用程序现在有serverendapp方案,服务器有clientendapp方案啊,即使添加了com.test前缀,它仍然不起作用。从你的观点来看,客户端应用程序应该指向serverapp的url方案,反之亦然。我这样做了,并负责这个项目。也清理了我的模拟器看起来你没有试过,错误完全一样,你100%确定所有设置都完全相同?在设备上运行,而不是在模拟器上运行。
 @IBAction func tapToServer(){
        let urlsrting = "com.test.clientEndApp://provideInfo?username='Debanjan'"
        let url = URL(string: urlsrting)!
        if UIApplication.shared.canOpenURL(url){
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(url, options: [:]) { (success) in
                    print(" this is \(success)")
                }

            } else {
                UIApplication.shared.openURL(url)
            }
        }else{
            let alertController = UIAlertController(title: "Error", message:
                "There is no such client app here", preferredStyle: .alert)
            alertController.addAction(UIAlertAction(title: "Dismiss", style: .default))

            self.present(alertController, animated: true, completion: nil)

        }
    }
}
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.test.clientEndApp</string>
</array>
let urlsrting = "com.test.clientEndApp://provideInfo?username='Debanjan'"