0

PhoneGapベースのアプリケーションを作成し、このリンクからダウンロードしたものと同じコードを含めました:Database.comを利用したPhoneGapモバイルアプリケーションの構築

アプリを実行すると、ログイン画面が表示されます。スクリーンショットは次のとおりです。 ここに画像の説明を入力してください

ログインボタンをクリックしても何も起こらないので、同じページにいます。私はすでに次のsalesforceWrapper.jsように自分のコシューマーキーをファイルに含めています:

function SalesforceWrapper() {
    /* AUTHENTICATION PARAMETERS */
    this.loginUrl = 'https://login.salesforce.com/';
    this.clientId = 'sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds';
    this.redirectUri = 'https://login.salesforce.com/services/oauth2/success';

    /* CLASS VARIABLES */
    this.cb = ChildBrowser.install(); //ChildBrowser in PhoneGap
    this.client = new forcetk.Client(this.clientId, this.loginUrl); //forceTk client instance

    this.init();
}

salesforeceログインページにリダイレクトできないのはなぜですか?コンソール出力は次のとおりです。

2012-06-25 16:20:53.023 J[2396:13403] Opening Url : https://login.salesforce.com/services/oauth2/authorize?display=touch&response_type=token&client_id=sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds&redirect_uri=https%3A//login.salesforce.com/services/oauth2/success
2012-06-25 16:20:53.024 J[2396:13403] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> Application tried to present modally an active controller <MainViewController: 0x9a67dc0>.
2012-06-25 16:20:53.034 J[2396:13403] ERROR whitelist rejection: url='https://login.salesforce.com/services/oauth2/authorize?display=touch&response_type=token&client_id=sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds&redirect_uri=https%3A//login.salesforce.com/services/oauth2/success'

ChildBrowserCommandフィールドとChildBrowserフィールドをCordova.plistに追加しました。 ここに画像の説明を入力してください

Index.htmlページにスクリプトファイルのパスを含めました。

<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>

これが私のXcodeプロジェクトのスクリーンショットです:

ここに画像の説明を入力してください

CDVPlugin参照の問題を解決し、WebKit discarded an uncaught exception問題が発生しました。どうすればこれを解決できますか?

Crodova.plistのExternalHostsにパラメーターを追加することで解決しました。 ここに画像の説明を入力してください

4

3 に答える 3

2

この問題に直面している他の人のために、

この問題は、イベント ハンドラーが適切にバインドされていないことが原因である可能性があります。- または複数回バインドされます (ほとんどの場合)。

プラグイン コードが複数回バインドされないようにするには、プラグイン コードにパッチを適用する必要がありますが、これを防ぐ簡単な方法は、jQuery で委任されたイベント ハンドラーを使用して、イベントがターゲットに 1 回だけバインドされるようにすることです。

于 2012-09-27T22:31:20.020 に答える
0

iOS 5でこの問題を抱えている他のすべての人にとって、問題は、Childbrowserが2回表示しようとしているため、エラーが発生することです。1つの解決策は、表示コードの周りにtrycatchをスローすることです。

つまり、これを変更します(ChildBrowserCommand.m-> showWebPage)

#ifdef CORDOVA_FRAMEWORK
CDVViewController* cont = (CDVViewController*)[ super viewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
childBrowser.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[ cont presentModalViewController:childBrowser animated:YES ];
#endif

これに:

#ifdef CORDOVA_FRAMEWORK
CDVViewController* cont = (CDVViewController*)[ super viewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
childBrowser.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
@try {
    [ cont presentModalViewController:childBrowser animated:YES ];
}@catch(NSException * e){
    NSLog(@"ALready visible");
}
#endif
于 2012-07-05T15:33:53.370 に答える
0
  • ChildBrowser プラグインに必要なマッピングを含むように Cordova.plist ファイルを編集しましたか?
  • ChildBrowser プラグインの .h .m ソース コードをプロジェクトに正しく含めましたか?
  • childbrowser.js ファイルをインクルードし、index.html ファイルにロードしましたか?

通常、問題の原因はこれらの問題の 1 つです。

于 2012-06-25T10:23:25.417 に答える