Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

social.js authorize UI crashes on android

$
0
0

Environment

  • OS: Mac OS X Yosemite 10.10
  • Titanium SDK: 3.4.0GA
  • Alloy: 1.5.1
  • Titanium Studio, build: 3.4.0.201409261227
  • Android Genymotion emulator: Release 4.3 - API 18

Problem

Upon calling the 'authorize' method, the loading view opens and then immediately crashes, resulting in the following error.

[INFO] : libc: Fatal signal 11 (SIGSEGV) at 0x00000014 (code=1), thread 2206 (KrollRuntimeThr)

The behavior is consistent. However, if I open and close a facebook authorize dialog before opening the twitter authorize dialog, the twitter dialog will usually work. The issue may lie in the "popIn" animation: it appears that the window expands beyond the mobile screen viewport, and will crash at about the time the window should zoom back into the viewport.

Has anyone else encountered this issue?

Code

INDEX.XML

<Alloy>
    <Window class="container">
        <View id="loginView">
            <Label id="tagline">test</Label>
            <Button class="login" id="fbLogin" onClick="facebookLogin">Login with Facebook</Button>
            <Button onClick="statusUpdate">Share on Facebook</Button>
 
            <Button class="login" id="twitterLoginButton" onClick="twitterLogin">Login with Twitter</Button>
            <Button onClick="twitterShare">Twitter Share</Button>
 
            <Label>Skip for Now...</Label>
        </View>
    </Window>
</Alloy>
INDEX.JS
$.index.addEventListener("open", function() {
    if (Ti.Platform.osname === "android") {
        if (! $.index.activity) {
            Ti.API.error("Can't access action bar on a lightweight window.");
        } else {
           $.index.activity.actionBar.hide();
        }
    }
});
 
var fb = Alloy.Globals.Facebook;
fb.appid = 000000; //actual appid has been removed
 
//actual consumer secret and key have been removed
var twitter = require('alloy/social').create({consumerSecret:'SHHHH...SECRET',consumerKey:'CLASSIFIED'});
 
fb.addEventListener('login', function(e){
    if(e.success){
        $.fbLogin.setTitle("Logout of Facebook");
        alert("Already logged in - go to another view.");
    }
});
fb.addEventListener('logout', function(e){
    $.fbLogin.setTitle("Login with Facebook");
});
if(twitter.isAuthorized()){
    $.twitterLoginButton.setTitle("Logout of Twitter");
}
else{
    $.twitterLoginButton.setTitle("Login with Twitter");
}
function statusUpdate(e){
    if (fb.loggedIn)
    {
        fb.dialog('share', {href:'http://google.com'}, callback);
    }
    else{
        alert("Please log into Facebook before sharing.");
    }
 
    function callback(e){
        if(e.success){
            Ti.API.info("Success: "+ e.result);
            alert("Message Posted Successfully.");
        }
        else if(e.error){
            Ti.API.info(e.error);
            alert("Message cannot be posted at this time.");
        }
    }
}
function facebookLogin(){
    if(fb.loggedIn){
        fb.logout();
    }
    else{
        fb.authorize();
    }
}
function twitterLogin(){
    if(!twitter.isAuthorized()){
        twitter.authorize(function(e){
            Ti.API.info(e);
            if(e.userid.length > 0){
                $.twitterLoginButton.setTitle("Logout of Twitter");
            }
        });
    }
    else{
        twitter.deauthorize();
        $.twitterLoginButton.setTitle("Login with Twitter");
    }
}
 
function twitterShare(){
    twitter.share({
        message:"Hello dudes! #devtest",
        success: function(e){alert("success");},
        error:function(e){alert("error");}
 
    });
}
 
$.index.open();

Stack Trace and Demo of Bug

Trace from logcat upon first call of the "authorize" method and a screen capture of the bug I'm encountering can be viewed from here.

Other notes

  • Line 514 of the social.js file makes use of the deprecated "Ti.UI.AUTODETECT_NONE"
  • The default navigation/action bar at the top becomes visible

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>