web-dev-qa-db-ja.com

AndroidカスタムURLスキームが機能しない/戻る方法Android App After OAuth

編集、問題のはるかに簡潔で単純な表示については、この質問の下の2番目の回答を参照してください


ようやく私の知恵は終わりました。私はチタンを使用してクロスプラットフォームアプリ(IOSとAndroid)に取り組んでおり、残りの呼び出しを介してsalesforce APIに接続しています。私はこの問題に3日と20時間を費やしましたが、それでも立ち往生しています。どんなサポートでも大歓迎です!それでは、詳しく見ていきましょう。

やりたいこと:アプリが起動し、ユーザーにoauth2認証を使用してトークンが付与されているかどうかを確認します。付与されていない場合は、salesforceログインを付与します画面。ユーザーが資格情報を入力して[許可]ボタンをクリックすると、その後、アプリにリダイレクトされます

問題:上記で何をしたいかという説明から、太字の最後の行を除いて、すべてが機能します。ユーザーが[許可]ボタンをクリックすると、次の不明なURLスキームエラーが表示されます。

error

コード:コードは3つの異なる重要な領域で構成されています

  • salesforceログイン呼び出しが行われる場所である私のindex.jsファイル
  • index.jsでsalesforceのURL情報が呼び出される私のAuthService.jsファイル
  • AndroidカスタムURLスキーム用に構成情報が保持される私のtiapp.xml

index.js

var Auth = require('AuthService');

Auth.openLogin();

AuthService.jsここでは「openLogin」関数のみが本当に重要です。

var loginWindow;

module.exports = {

  get: function () {
    console.log("made it into the auth.get function");
    return Ti.App.Properties.getObject('auth');
  },

  set: function (data) {
    Ti.App.Properties.setObject('auth', data);
    console.log("auth set function was executed!!!");
  },

  erase: function () {
    Ti.App.Properties.removeProperty('auth');
  },

  openLogin: function () {

    console.log("made it into openLogin!!");


   var webview = Titanium.UI.createWebView({url:'https://login.salesforce.com/services/oauth2/authorize' +
      '?response_type=token&display=touch' +
      '&redirect_uri=testapp://app.open' +
      '&client_id=' + Ti.App.Properties.getString('salesforce_client_id')});


      //console.log("Webview URL: " + webview.getUrl());

    loginWindow = Titanium.UI.createWindow();
    loginWindow.add(webview);
    loginWindow.open({modal:true});



    // attempt to log url to console here
    //console.log("this is the webview URL during callback: " +  webview.getUrl());

  },

  closeLogin: function () {
    loginWindow.close();
  }

};

tiapp.xml私は自分のAndroidこのセクションを簡潔にするためにのみ含めています)

<Android xmlns:Android="http://schemas.Android.com/apk/res/Android"> 
        <manifest Android:versionCode="1" Android:versionName="1.00">
            <uses-permission Android:name="Android.permission.INTERNET"></uses-permission>
            <uses-permission Android:name="Android.permission.ACCESS_NETWORK_STATE"></uses-permission>
            <uses-permission Android:name="Android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
            <uses-permission Android:name="Android.permission.ACCESS_FINE_LOCATION"></uses-permission>
            <uses-permission Android:name="Android.permission.ACCESS_WIFI_STATE"></uses-permission>
        </manifest>


        <activity
      Android:name=".TesterActivity"
      Android:exported="true"
      Android:label="@string/app_name" >
      <intent-filter>
          <data Android:Host="app.open" Android:scheme="testapp" />
          <action Android:name="Android.intent.action.VIEW" />
          <category Android:name="Android.intent.category.BROWSABLE" />
          <category Android:name="Android.intent.category.DEFAULT" />
      </intent-filter>
  </activity>

    </Android>

Salesforceに登録されているコールバックURL:enter image description here

私が試したもの:私はこの問題について自分自身を青くググった。私のいじくりのほとんどは、Androidタグ内のプロパティとそれらのプロパティの値の変更、および私の「AuthService.js」ファイルとsalesforceの「callback url」フィールド(これらの値が一致する必要があるか、URIの不一致エラーが発生するため)。

私の問題を解決するために私が調べ、試みたいくつかの解決策は次のとおりです: https://Gist.github.com/jasonkneen/5736738

AndroidカスタムURLスキーム..?

独自のURIスキームをAndroidに実装する方法

ほんの数例を挙げると。

アプリ実行時のコンソールログ:

[INFO] :   Emulator is booted
[INFO] :   SD card not required, skipping mount check
[INFO] :   Emulator ready!
[INFO] :   Creating unsigned apk
[INFO] :   Processing /Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/src
[INFO] :   Writing unsigned apk: /Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/app-unsigned.apk
[INFO] :   Using MD5withRSA signature algorithm
[INFO] :   Signing apk: /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/bin/jarsigner "-sigalg" "MD5withRSA" "-digestalg" "SHA1" "-keystore" "/Users/michael.kellogg/Library/Application Support/Titanium/mobilesdk/osx/5.1.2.GA/Android/dev_keystore" "-storepass" "*******" "-signedjar" "/Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/tester.apk" "/Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/app-unsigned.apk" "tidev"
[INFO] :   Aligning Zip file: /Users/michael.kellogg/Android-sdk/build-tools/23.0.2/zipalign "-v" "4" "/Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/tester.apk" "/Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/tester.apkz"
[INFO] :   Writing build manifest: /Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/build-manifest.json
[INFO] :   Making sure the adb server is running
[INFO] :   Installing apk: /Users/michael.kellogg/Documents/Appcelerator_Studio_Workspace/tester/build/Android/bin/tester.apk
[INFO] :   App successfully installed
[INFO] :   Starting app: com.test.test/.TesterActivity
[INFO] :   Application pid: 1160
[INFO] :   Project built successfully in 3m 8s 295ms
[INFO] :   art: Late-enabling JIT
[INFO] :   art: JIT created with code_cache_capacity=2MB compile_threshold=1000
[INFO] :   TiApplication: (main) [2,2] checkpoint, app created.
[INFO] :   TiApplication: (main) [1067,1069] Titanium 5.1.2 (2015/12/16 19:00 ca822b2)
[INFO] :   art: Background sticky concurrent mark sweep GC freed 15623(973KB) AllocSpace objects, 11(384KB) LOS objects, 41% free, 2MB/3MB, paused 2.142ms total 105.631ms
[INFO] :   TiApplication: (main) [383,1452] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[WARN] :   TiTempFileHelper: (main) [189,189] The external temp directory doesn't exist, skipping cleanup
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.test.test.TesterActivity@a298e02
[WARN] :   V8Object: (KrollRuntimeThread) [1039,1228] Runtime disposed, cannot set property 'userAgent'
[INFO] :   made it into openLogin!!
[INFO] :   OpenGLRenderer: Initialized EGL, version 1.4
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4d32b20, error=EGL_SUCCESS
[INFO] :   WebViewFactory: Loading com.Android.webview version 44.0.2403.119 (code 246011900)
[WARN] :   System: ClassLoader referenced unknown path: /system/app/webview/lib/arm
[INFO] :   LibraryLoader: Time to load native libraries: 36 ms (timestamps 588-624)
[INFO] :   LibraryLoader: Expected native library version number "",actual native library version number ""
[INFO] :   LibraryLoader: Expected native library version number "",actual native library version number ""
[INFO] :   chromium: [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0
[INFO] :   BrowserStartupController: Initializing chromium process, singleProcess=true
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[ERROR] :  SysUtils: ApplicationContext is null in ApplicationStatus
[WARN] :   chromium: [WARNING:resource_bundle.cc(285)] locale_file_path.empty()
[ERROR] :  libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
[ERROR] :  libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
[ERROR] :  eglCodecCommon: glUtilsParamSize: unknow param 0x00008d57
[WARN] :   AudioManagerAndroid: Requires BLUETOOTH permission
[ERROR] :  DataReductionProxySettingListener: No DRP key due to exception:Java.lang.ClassNotFoundException: com.Android.webview.chromium.Drp
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   AwContents: onDetachedFromWindow called when already detached. Ignoring
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   chromium: [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4d32b40, error=EGL_SUCCESS
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 7564(860KB) AllocSpace objects, 25(988KB) LOS objects, 0% free, 11MB/11MB, paused 1.603ms total 308.766ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 1948(144KB) AllocSpace objects, 3(8MB) LOS objects, 22% free, 13MB/17MB, paused 1.658ms total 271.298ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 148(6KB) AllocSpace objects, 13(36MB) LOS objects, 17% free, 19MB/23MB, paused 1.205ms total 327.978ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 91(3KB) AllocSpace objects, 5(14MB) LOS objects, 22% free, 13MB/17MB, paused 1.228ms total 201.595ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Suspending all threads took: 15.737ms
[INFO] :   art: Background sticky concurrent mark sweep GC freed 261(13KB) AllocSpace objects, 2(5MB) LOS objects, 0% free, 25MB/25MB, paused 18.832ms total 174.330ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 98(20KB) AllocSpace objects, 7(19MB) LOS objects, 26% free, 11MB/15MB, paused 3.244ms total 302.681ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 1160
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 11512(602KB) AllocSpace objects, 0(0B) LOS objects, 4% free, 14MB/15MB, paused 1.739ms total 174.806ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 301(32KB) AllocSpace objects, 2(5MB) LOS objects, 25% free, 11MB/15MB, paused 2.370ms total 274.103ms
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9d719f80, error=EGL_SUCCESS
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 358(19KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 17MB/17MB, paused 6.593ms total 277.832ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 148(5KB) AllocSpace objects, 3(8MB) LOS objects, 18% free, 17MB/21MB, paused 7.547ms total 414.524ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 30(608B) AllocSpace objects, 1(2MB) LOS objects, 0% free, 23MB/23MB, paused 2.321ms total 159.615ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 36(1168B) AllocSpace objects, 5(14MB) LOS objects, 21% free, 14MB/18MB, paused 1.626ms total 197.175ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 21(448B) AllocSpace objects, 0(0B) LOS objects, 0% free, 20MB/20MB, paused 37.280ms total 96.680ms
[INFO] :   art: Background partial concurrent mark sweep GC freed 34(960B) AllocSpace objects, 4(11MB) LOS objects, 30% free, 8MB/12MB, paused 1.475ms total 106.381ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 56(3KB) AllocSpace objects, 3(8MB) LOS objects, 21% free, 14MB/18MB, paused 3.001ms total 243.577ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 1160
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 1160
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 1160
[INFO] :   I/TiWebChromeClient.console: (main) [21796,21796] Not allowed to load local resource: file:///Android_asset/webkit/Android-weberror.png (0:data:text/html,chromewebdata)
[INFO] :   art: Background sticky concurrent mark sweep GC freed 337(53KB) AllocSpace objects, 1(2MB) LOS objects, 6% free, 17MB/18MB, paused 43.249ms total 82.260ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 82(11KB) AllocSpace objects, 3(8MB) LOS objects, 21% free, 14MB/18MB, paused 1.613ms total 159.713ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background sticky concurrent mark sweep GC freed 27(544B) AllocSpace objects, 1(2MB) LOS objects, 6% free, 17MB/18MB, paused 21.912ms total 68.965ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[INFO] :   art: Background partial concurrent mark sweep GC freed 39(1056B) AllocSpace objects, 3(8MB) LOS objects, 21% free, 14MB/18MB, paused 1.523ms total 136.698ms
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[WARN] :   art: Attempt to remove non-JNI local reference, dumping thread
[ERROR] :  Surface: getSlotFromBufferLocked: unknown buffer: 0xaad48dc0
[INFO] :   art: Background partial concurrent mark sweep GC freed 40(1104B) AllocSpace objects, 5(14MB) LOS objects, 25% free, 11MB/15MB, paused 3.871ms total 157.623ms
[INFO] :   APSAnalyticsService: Analytics Service Started
[INFO] :   APSAnalyticsService: Stopping Analytics Service
-- End application log -------------------------------------------------------
12
Mike Kellogg

64時間のインターネット探索と無数の試みの後で、ようやくこの問題の解決策を見つけました。イエーイ!この問題が解決するまでにかかった時間については少し恥ずかしいと思います。

問題:Android appにSalesforceの承認後にナビゲートする方法が見つかりませんでした(カスタムURLスキームは非常にAndroidで苦痛)。

解決策:周りを検索した後、私がここでやろうとしていたことを実行するSalesforceのコード例を見つけました:

https://developer.salesforce.com/page/Developing_Mobile_Applications_with_Force.com_and_Appcelerator_Titanium

上記の記事で提供されている、非常に必要なコードを含むgithubリンクは次のとおりです。

https://github.com/appcelerator-developer-relations/Force

TLDR:ここでの実際のキーは、AndroidおよびチタンでカスタムURLスキームを使用しないことでした。代わりにgithubコード上記のリストは、Webビューで認証ページを開き、リスナーを使用して、認証が完了した後にそのWebビューを閉じて、必要なビューを開きます。

説明:IOS私がしなければならなかったすべてのことは、カスタムurlスキームを使用するためのtiapp.xmlファイル。これは非常に迅速かつ簡単に機能し、頭痛の種はありませんでした。当然、カスタムurlスキームはAndroidを使用する方法だと思いましたが、間違いはありませんか?false。上記のように多くの時間を費やしました。 AndroidでカスタムURLスキームを作成しようとしています。有効ではありません。AndroidカスタムURLスキームについてオンラインでたくさんの情報があるようですが、どれもうまくいきませんでした多くのことを試しました(結局それは約64時間でした)結局私はオンラインで自分のやりたいことを実行するコードの例を見つけようとしましたが、これは私が見つけたものです。

5
Mike Kellogg

スキーマ認識のためのマニフェストを設定するという点では、次のようなものになるはずです

<manifest ...>
    ...
    <application ...>
        ...
        <activity ...
            Android:exported="true"> <!-- Make it exported -->
            <intent-filter>
                <action Android:name="Android.intent.action.MAIN" />
                <category Android:name="Android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter Android:label="...">
                <action Android:name="Android.intent.action.VIEW" />
                <category Android:name="Android.intent.category.DEFAULT" />
                <category Android:name="Android.intent.category.BROWSABLE" />
                <data Android:scheme="testapp" />
                <data Android:Host="app" /> <!-- cover all your bases -->
                <data Android:Host="app.open" />
            </intent-filter>
        </activity>
    </application>
</manifest>

次に、そのアクティビティにメソッドがあり、スキーマが意図したものであるかどうかを確認できます。次のようなもの:

protected void onCreate(final Bundle savedInstanceState) {
    ...
    checkIntent( getIntent() );
} 

protected void onNewIntent(final Intent intent) {
    ...
    checkIntent( intent );
}

private void checkIntent(Intent intent) {
    if ( intent.getDataString() != null && Intent.ACTION_VIEW.equals(intent.getAction()) ) {
        //If we reached here we have some kind of deep link or custom schema
        //so lets identify which schema
        if ( "testapp".equals(data.getScheme().toLowerCase()) ) {
            //my tests were able to reach here
        }
    }
}

Androidのquirkの1つは、それ以降のバージョンでは、ユーザーはshow intentを実行する必要があることです。つまり、ブラウザでURLを入力して[実行]を押しても機能しません。これは、ユーザーがリンクをクリックしたとき、またはインテントを起動したときにのみトリガーされます。 (外部ブラウザではなく)自分のWebViewからのリダイレクトのみを検出したい場合、それを回避することができます:

myWebView.setWebViewClient( new WebViewClient() {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("testapp://")) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData( Uri.parse(url) );
            view.getContext().startActivity( intent );
            return true; //with return true, the webview wont try rendering the url
        }
        return false;
    }

} );
9
Temporary

コメントに入れられなかったため、回答を作成しました。試してみて、効果があるかどうかを確認してください。

<Android xmlns:Android="http://schemas.Android.com/apk/res/Android">
<manifest>
    <application Android:icon="@drawable/appicon" Android:label="MyApp" Android:name="MyApplication">
        <activity Android:label="MyApp" Android:name=".MyApplicationActivity">
            <intent-filter>
                <action Android:name="Android.intent.action.MAIN"/>
                <category Android:name="Android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action Android:name="Android.intent.action.VIEW" />
                <category Android:name="Android.intent.category.DEFAULT" />
                <category Android:name="Android.intent.category.BROWSABLE" />
                <data Android:scheme="mytestapplication" />
            </intent-filter>
        </activity>
    </application>
</manifest>

これを試してみて、うまくいくかどうか確認してください。この Git Post で言及されているTiApp.xmlエントリを確認することもできます。

これを試しても問題が解決しない場合は、別の方法を試してみてください。

2
Soumya

私には正当に見えるいくつかの回避策があります。したがって、shouldOverrideUrlLoading()とともにWebViewClientonErrorRecieved()をオーバーライドすることができ、実際にはfailingUrlを引数として渡します。

private val webViewClient = object : WebViewClient() {

        @Suppress("OverridingDeprecatedMember")
        override fun onReceivedError(view: WebView?, errorCode: Int, description: String?, failingUrl: String?) {
            if (failingUrl != null) {
                handleCallbackUrl(Uri.parse(failingUrl))
            }
        }

        override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?) = when {
            handleCallbackUrl(request?.url) -> true
            else -> super.shouldOverrideUrlLoading(view, request)
        }
}
0
Ivan