私はjQuery MobileとPHP(CodeIgniterフレームワーク)で構築されたWebアプリケーションを持っています。今私はそれをPhoneGapのバージョンにしてスタンドアロンのアプリケーションとして配布できるようにしようとしています。しかし、PHPのWebアプリケーション。バージョンは、認証のためのCodeIgniterプラグインであるIon Authを使用します。認証が必要なページに行くと、認証コントローラのログインメソッドにリダイレクトされます。認証の後、ホームページ(この場合はjQuery Mobileページ)にリダイレクトされます。とにかく家のページが家のコントローラによって最初に開かれているので、これはウェブアプリでうまくいきます。jQuery MobileとPhoneGapの認証
しかし、ここでの要点は:PhoneGapバージョンでは、「ホーム」ページはPhoneGapのindex.htmlファイルである必要があります。明らかにPhoneGap.plistに値を追加して起動時に別のURLを読み込むことはできますが、それはAppleがApp Storeに送信するために受け入れられません。また、認証でリダイレクトを行うと、認証後にindex.htmlファイルに戻ることができません。
PhoneGap/jQuery Mobileアプリでの認証方法を教えてください。
UPDATE:
私はこの答えの一つに記載しようとしているが、アプリはまだ私はちょうどからログインしたい場合、(存在しない)アカウント/ログインページに移動しようとしますポストとメソッドから値を返す:私は削除またはがあった任意のリダイレクトをコメントアウトしていると思います
function login()
{
//validate form input
$this->form_validation->set_rules('identity', 'Identity', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$base_url = $this->config->item('base_url');
$mobile = $this->detect_mobile();
if ($mobile === false && $base_url != 'http://localhost/app_xcode/') //Only restrict if not developing
redirect('account/notAMobile');
else if ($this->form_validation->run() == true) { //check to see if the user is logging in
//check for "remember me"
$remember = (bool)$this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { //if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
echo true;
/*redirect($this->config->item('base_url'), 'refresh');*/
}
else
{ //if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
/*redirect('account/login', 'refresh');*/ //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{ //the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors()
: $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
}
}
:
$('#login_form').bind('submit', function() {
event.preventDefault();
//send a post request to your web-service
$.post('http://localhost/app_xcode/account/login', $(this).serialize(), function (response) {
//parse the response string into an object
var response = response;
//check if the authorization was successful or not
if (response == true) {
$.mobile.changePage('#toc', "slide");
} else {
alert('login failed');
$.mobile.changePage('#toc', "slide");
}
});
});
は、ここでコントローラのメソッドです。だから私はなぜそれがまだビューを読み込もうとするのか分からないのですか?私はそのURLに投稿するので、そこにナビゲートしようとしているjQuery Mobileと何か関係がありますか?
ありがとう、ありがとう。実際にはWebサービスではなく、CodeIgniterのプラグインです。私はあなたの例のようなものを持っています。唯一の問題は、アカウント/ログイン(アカウントコントローラのログインメソッド)に投稿するとログインしますが、ビューアカウント/ログインにナビゲートしようとすることにもなります。私はそれを望んでいない。値を返すだけですが(値は返されますがそれでもログインページに移動しようとしています...私の更新を見てください) – Anders
私はそれを理解したので、今働いています。ありがとう。 – Anders
今後これを見ている人は知っています、あなたの解決策は何ですか? – Jasper