development

URL SCHEME으로 Instagram 앱을 열지 않는 iOS 9

big-blog 2020. 6. 24. 07:06
반응형

URL SCHEME으로 Instagram 앱을 열지 않는 iOS 9


다음 URL은 iOS 8.3 이하에서 열리지 만 작동하지 않으며 iOS 9

let instagramURL = NSURL(string: "instagram://app")

왜 URL이 열리지 않습니까?


iOS 9은 URL 스킴 처리를 약간 변경했습니다. 앱에서 LSApplicationQueriesSchemes를 사용하여 호출 할 URL을 허용 목록에 추가해야 합니다 Info.plist.

여기에 게시물을 참조하십시오 : http://awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes

주요 결론은 다음과 같습니다.

허용 목록에없는 URL에서 "canOpenURL"메서드를 호출하면이 체계를 처리하도록 등록 된 앱이 설치되어 있어도 "NO"가 반환됩니다. "이 응용 프로그램은 체계 xxx를 쿼리 할 수 ​​없습니다"syslog 항목이 나타납니다.

허용 목록에없는 URL에서 "openURL"메서드를 호출하면 자동으로 실패합니다. "이 응용 프로그램은 체계 xxx를 쿼리 할 수 ​​없습니다"syslog 항목이 나타납니다.

저자는 또한 이것이 OS의 버그이며 애플은 다음 릴리스에서이 문제를 해결할 것이라고 추측합니다.


위에서 말했듯이 정보 plist에 키를 추가하려고합니다. 여기에 대부분의 소셜 네트워크 목록이 있습니다.

<key>LSApplicationQueriesSchemes</key>
    <array>
     <string>fb</string>
     <string>fbapi</string>
     <string>fbauth2</string>
     <string>fbshareextension</string>
     <string>fb-messenger-api</string>
     <string>twitter</string>
     <string>viber</string>
     <string>whatsapp</string>
     <string>wechat</string>
     <string>line</string>
     <string>instagram</string>
     <string> instagram-stories</string>
     <string>kakaotalk</string>
     <string>mqq</string>
     <string>vk</string>
     <string>comgooglemaps</string>
     <string>googlephotos</string>
     <string>ha</string>
     <string>yammer</string>
    </array>

* 처음 3 개 일치 Facebook (FBSDK 4.6) : fbapi, fbauth2, fbshareextension. "Ha"는 스냅 챗입니다


이것은 iOS 9의 새로운 보안 기능입니다 . 자세한 정보는 WWDC 2015 세션 703 을보십시오.

SDK 9로 빌드 된 모든 앱 LSApplicationQueriesSchemes은 plist 파일에 항목 을 제공 하여 쿼리하려는 구성표를 선언해야합니다.

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>urlscheme</string>
 <string>urlscheme2</string>
 <string>urlscheme3</string>
 <string>urlscheme4</string>
</array> 

두 개의 앱 TestA와 TestB를 가정합니다. TestB는 TestA가 설치되어 있는지 조회하려고합니다. "TestA"는 info.plist 파일에서 다음 URL 체계를 정의합니다.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>testA</string>
        </array>
    </dict>
</array>

두 번째 앱 "TestB"는 다음을 호출하여 "TestA"가 설치되어 있는지 확인합니다.

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"TestA://"]];

그러나 "TestA"를 TestB info.plist 파일의 LSApplicationQueriesSchemes 항목에 추가해야하므로 iOS9에서 NO를 반환합니다. 다음 코드를 TestB의 info.plist 파일에 추가하면됩니다.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>TestA</string>
</array>

실제 구현은 https://github.com/gatzsche/LSApplicationQueriesSchemes-Working-Example 에서 찾을 수 있습니다.


세션 703 WWDC 2015에서 :

iOS 9 용 앱을 빌드 할 때 URL 스킴을 계속 사용할 수 있으며 URL 스킴을 호출하려면 앱 Info.plist에서이를 선언해야합니다. 새로운 키가 LSApplicationQueriesSchemes있으며 여기에 canOpenURL을 사용하려는 구성표 목록을 추가해야합니다.

예를 들어 FB의 경우


@Matthieu 답변 (나머지 소셜 URL의 경우 100 % 정확함)로도 공유 대화 상자에서 Facebook을 공유 할 수 없습니다. Facebook SDK에서 반전 한 URL 세트를 추가해야했습니다.

<array>
        <string>fbapi</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
        <string>fb-messenger-api</string>
        <string>twitter</string>
        <string>whatsapp</string>
        <string>wechat</string>
        <string>line</string>
        <string>instagram</string>
        <string>kakaotalk</string>
        <string>mqq</string>
        <string>vk</string>
        <string>comgooglemaps</string>
        <string>fbapi20130214</string>                                                    
        <string>fbapi20130410</string>                                                     
        <string>fbapi20130702</string>                                                    
        <string>fbapi20131010</string>                                                    
        <string>fbapi20131219</string>                                                    
        <string>fbapi20140410</string>                                                     
        <string>fbapi20140116</string>                                                     
        <string>fbapi20150313</string>                                                     
        <string>fbapi20150629</string>
    </array>

9.0.x에서 탈옥 된 전화기에 URL 스킴이있는 버그가 있음에 유의해야합니다. 탈옥 된 장치를 사용하는 경우 Cydia에서 Patcyh를 업데이트하십시오


조건부 검사없이 직접 openURL:또는 openURL:options:completionHandler:(iOS 10 이상) 을 호출하여 앱을 열 수 있습니다 canOpenURL:. canOpenURL : 메소드에 대한 Apple 문서토론 섹션읽으십시오 .

openURL : 메소드는 LSApplicationQueriesSchemes요구 사항에 의해 제한되지 않습니다 .


Swift 4.2 및 Xcode 10.1에서

info.plist에서 CFBundleURLSchemes 및 LSApplicationQueriesSchemes를 추가해야합니다.

-> 프로젝트에서 info.plist를 선택하십시오.

-> 오른쪽 클릭

-> 소스 코드로 열기를 선택하십시오.

아래 스크린 샷을 참조하십시오

여기에 이미지 설명을 입력하십시오

-> xml 파일이 열립니다

-> 복사-아래 코드를 붙여 넣고 ID로 바꿉니다.

gmail, fb, twitter 및 링크 된 CFBundleURLSchemes 및 LSApplicationQueriesSchemes

<key>CFBundleURLTypes</key>
    <array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>li5****5</string>
            <string>com.googleusercontent.apps.8***************5f</string>
            <string>fb8***********3</string>
            <string>twitterkit-s***************w</string>
        </array>
    </dict>
</array>
<key>FacebookAppID</key>
<string>8*********3</string>
<key>FacebookDisplayName</key>
<string>K************ app</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>

    <string>twitter</string>
    <string>twitterauth</string>

    <string>linkedin</string>
    <string>linkedin-sdk2</string>
    <string>linkedin-sdk</string>

</array>

See below screen your final info.plist file is

여기에 이미지 설명을 입력하십시오


It doesn't seem anyone has addressed how to specify URLs with embedded parameters. Any URL that contains parameters it won't possible to specify the specific URL in LSApplicationsQueriesSchemes. For example, assume I have an email app that passes the the senders email address:

myemail://mailto?bob@gmail.com

The only way it seems to get it to work in iOS9 is to remove any parameters.


Apple changed the canOpenURL method on iOS 9. Apps which are checking for URL Schemes on iOS 9 and iOS 10 have to declare these Schemes as it is submitted to Apple.


For PayPal add below URL schemes :

여기에 이미지 설명을 입력하십시오

Refer this link


Swift 3.1, Swift 3.2, Swift 4

if let urlFromStr = URL(string: "instagram://app") {
    if UIApplication.shared.canOpenURL(urlFromStr) {
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(urlFromStr, options: [:], completionHandler: nil)
        } else {
            UIApplication.shared.openURL(urlFromStr)
        }
    }
}

Add these in Info.plist :

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
</array>

오늘 내 앱에서 Facebook에 전화를 걸려 LSApplicationQueriesSchemes고 할 때 Info.plist(Xcode 버전 8.2.1 (8C1002))에 추가 할 수 있는 가 없다는 것을 알았습니다. Sublime Text로Info.plist with를 열고 파일에 수동으로 추가 한 다음 작동했습니다. 키를 찾을 수없는 경우 직접 추가하면됩니다.

참고 URL : https://stackoverflow.com/questions/30987986/ios-9-not-opening-instagram-app-with-url-scheme

반응형