简体   繁体   English

Sencha Touch 2:如何添加Google+登录?

[英]Sencha Touch 2: How can I add Google+ Login?

I would like to add a Google+ Login to my Sencha Touch 2 webapplication, according to https://developers.google.com/+/web/signin/?hl=de#using_the_client-side_flow . 根据https://developers.google.com/+/web/signin/?hl=de#using_the_client-side_flow ,我想将Google+登录名添加到我的Sencha Touch 2 Web应用程序中。

I have added the google script into the app.json (defined as remote script) and it gets loaded. 我已经将Google脚本添加到app.json(定义为远程脚本)中,并且已加载该脚本。 I created a Container with the html stuff (described by google): 我创建了一个带有html内容的容器(由google描述):

Ext.define('Bubbles.view.LoginView', {
extend: 'Ext.Container',
id: 'loginView',
config: {
    fullscreen: true,
    layout: 'fit',
    html: '<span id=\"signinButton\">'
        +   '<span class="g-signin" data-callback="signinCallback" data-clientid="CLIENT_ID" data-cookiepolicy="single_host_origin" data-requestvisibleactions="http://schemas.google.com/AddActivity" data-scope="https://www.googleapis.com/auth/plus.login"></span>'
        + '</span>',
    height: '100%',
    width: '100%',
}});

But the screen stays empty, no login button :-( 但是屏幕保持空白,没有登录按钮:-(

However, removing this html section above and adding it directly into index.html works. 但是,删除上面的html部分并将其直接添加到index.html即可。 Unfortunately, this is a very bad practice... 不幸的是,这是非常糟糕的做法...

Any ideas how to do it properly with Sencha Touch 2? 有任何想法如何使用Sencha Touch 2正确执行操作吗?

It's probably not working because the .g-signin element is getting added to the dom after after Google tries to render the button. 这可能不起作用,因为在Google尝试渲染按钮后, .g-signin元素已添加到dom中。 Take a look at adding the sign-in button to your page with JavaScript . 看看如何使用JavaScript将登录按钮添加到您的页面 Especially step four where gapi.signin.render('myButton', additionalParams); 尤其是第四步,其中gapi.signin.render('myButton', additionalParams); is used to render the button. 用于渲染按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM