概要
以下の記事に従い、ionicで$cordovaOauth.twitterを使ってユーザー認証をしようとしたところ、動かない。logにも、console.log(error);
部分は何も出力されず、nullになってしまう。
- Displaying the Twitter Feed within Your Ionic App | The Official Ionic Blog
- ngCordova - Document and Examples - by the Ionic Framework Team
$cordovaOauth.twitter(ConsumerKey, ConsumerKeySecret).then(function(result) {
console.log('success');
console.log(result);
}, function(error) {
console.log('error');
console.log(error);
});
解決方法
ng-cordova-oauthのIssueを検索したところ、以下の様な記事を発見。
- Twitter Ouath · Issue #39 · nraboy/ng-cordova-oauth
- In App Browser opening to ( and sticking on ) blank screen · Issue #96 · nraboy/ng-cordova-oauth
- Google errors with "Cannot authenticate via a web browser" · Issue #28 · nraboy/ng-cordova-oauth
これらによると、ionicのlivereload
を使うな、ということらしい。
livereload
せずにionic:emulate:ios
を実行して、正常な処理が行われるようになった。