Oauth.io phonegap社交登录名(在文件:///中找不到主机名) [英] Oauth.io phonegap social login (cannot find hostname in file:///)

查看:80
本文介绍了Oauth.io phonegap社交登录名(在文件:///中找不到主机名)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已包含oauth.js文件.我正在使用以下代码初始化oauth

I have included oauth.js file. I am initializing the oauth using following code

OAuth.initialize('public-key');
OAuth.popup('twitter', function(error, result) {
                console.log(result);
                //handle error with error
                //use result.access_token in your API request
                result.get('/1.1/account/verify_credentials.json').done(function(data) {
                    console.log(data)
                    alert('Hello ' + data.name)
                })
            });

它可以在浏览器中正常运行,但不能在设备中运行.

Its properly working in browser but not in device.

我试图在config.xml中包含以下插件

I have tried to include following plugin in config.xml

<gap:plugin name="OAuth.io" value="com.phonegap.plugins.oauthio" version="0.1.1"/>

但是在[https://build.phonegap.com/][1]中创建版本时,我收到此插件不支持phonegap"消息.

But i am getting "this plugin is not supported for phonegap" message at the time of creating the build in [https://build.phonegap.com/][1].

所以我已经删除了该插件并创建了.apk文件并在设备中执行.屏幕快照中提到了它的跟踪错误.

So I have removed that plugin and created the .apk file and executed in device. Its getting following error which is mentioned in screen shot.

请指导我.谢谢.

推荐答案

1)从您的html中删除对oauthio js文件的引用(phonegap会注入它)

1) Remove the reference to the oauthio js file from your html (phonegap will inject it)

2)确保在所有内容之前都包含phonegap.js或cordova.js.

2) Make sure you have included phonegap.js or cordova.js before everything.

3)确保触发设备就绪事件后,正在初始化oauthio.

3) Make sure that you are initialising the oauthio after the device ready event has been fired.

document.addEventListener('deviceready',function(){OAuth.initialize('app_id');},false)

document.addEventListener('deviceready', function(){ OAuth.initialize('app_id'); }, false)

这篇关于Oauth.io phonegap社交登录名(在文件:///中找不到主机名)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆