用于adhoc发行的钛iOS应用程序卡在启动画面上

时间:2017-08-31 23:33:36

标签: javascript ios titanium appcelerator

我正在运行一个钛iOS应用程序,当我从appcelerator工作室运行它时,它在模拟器和设备上按预期工作,但是当我打包应用程序进行adhoc分发并将其安装在我的iPhone设备上时通过iTunes,它只会停留在启动画面上。

另外我无法调试,因为它是adhoc发行版。我注意到使用警报的唯一方法是它通过alloy.js运行但从未进入index.js

任何帮助都将不胜感激。

编辑:这些是我的索引和合金文件。

index.js

// Arguments passed into this controller can be accessed via the `$.args` object directly or:
var args = $.args;
var webServices = require("webService");
var TAG = "[loginActivity.js] : ";
var fb = Alloy.Globals.Facebook;
var win = $.window;
var core = require("core");
var network = require("NETWORK");



sessionStatus = Ti.App.Properties.getBool('session');
console.log("session estatus "+sessionStatus);
if(!sessionStatus)
    Ti.App.Properties.setBool('session', false);

sessionStatus = Ti.App.Properties.getBool('session');
console.log("session estatus "+sessionStatus);
Ti.App.session=sessionStatus;


manageLogin();

Ti.App.addEventListener('resumed',function(e){
   //check if login is still valid
   console.log("hola");
   manageLogin(); //I just reuse my login logic on resume
});


function manageLogin(){
    if(Ti.App.session==false){
    //  require("core").openLogin;
    console.log("abro login");
    openLogin();
    }else{
        console.log("abro main");
        Ti.App.User_id= Ti.App.Properties.getInt('User_id');
        //Ti.App.profIm =Ti.App.Properties.getObject('image');
       require("core").openMainActivity();
    }   
}






function openLogin(){
console.log("First attempt to use geolocation services.");
var hasLocationPermissions = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE);
Ti.API.info('Ti.Geolocation.hasLocationPermissions', hasLocationPermissions);

if (hasLocationPermissions) {
    console.log("GPS permissions granted.");

    open();
} else {

    console.log("Second attempt");
    Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) {

        if (e.success) {
            // $.index.open();
            open();
        } else {
            console.log("Something happened during second attempt");
            if (OS_ANDROID) {
                //alert('You denied permission for now, forever or the dialog did not show at all because you denied it forever earlier.');
                var activity = Titanium.Android.currentActivity;
                activity.finish();
                open();
            }
            // We already check AUTHORIZATION_DENIED earlier so we can be sure it was denied now and not before
            Ti.UI.createAlertDialog({
                title : 'You denied permission.',
                // We also end up here if the NSLocationAlwaysUsageDescription is missing from tiapp.xml in which case e.error will say so
                message : e.error
            }).show();
        }
    });
}

}


function open(e) {
    var nextWin = core.createWindow({
        controllerName : "loginActivity"
    });
    if (OS_ANDROID) {
        nextWin.fbProxy = Alloy.Globals.Facebook.createActivityWorker({lifecycleContainer: nextWin});
    }
    nextWin.addEventListener("postlayout", function checkGPS(e){
        nextWin.removeEventListener("postlayout", checkGPS);
        if(Ti.Geolocation.getLocationServicesEnabled() === false) {
            if(OS_ANDROID){
                var alertDlg = Titanium.UI.createAlertDialog({
                    title:'GPS apagado', 
                    message:'El GPS está apagado. Enciéndelo en ajustes.',
                    buttonNames: ['No encender el gps', 'Abrir ajustes']
                });
                alertDlg.cancel = 0;

                alertDlg.addEventListener('click', function(e){
                    if(!e.cancel) {
                        //open up the settings page
                        var settingsIntent = Titanium.Android.createIntent({
                            action: 'android.settings.LOCATION_SOURCE_SETTINGS'
                        });
                        Titanium.Android.currentActivity.startActivity(settingsIntent);
                    }
                });

                alertDlg.show();
            }
            else {
                alert("No se detecta tu ubicación, te recomendamos encender el GPS antes de iniciar la aplicación.");
            }
        }
    });
    nextWin.open();
}

和alloy.js

(function(){
    var ACS = require('ti.cloud'),
        env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development',
        username = Ti.App.Properties.getString('acs-username-'+env),
        password = Ti.App.Properties.getString('acs-password-'+env);

    // if not configured, just return
    if (!env || !username || !password) { return; }
    /**
     * Appcelerator Cloud (ACS) Admin User Login Logic
     *
     * fires login.success with the user as argument on success
     * fires login.failed with the result as argument on error
     */
    ACS.Users.login({
        login:username,
        password:password,
    }, function(result){
        Ti.API.info("Yes, logged in.");
        if (env==='development') {
            Ti.API.info('ACS Login Results for environment `'+env+'`:');
            Ti.API.info(result);
        }
        if (result && result.success && result.users && result.users.length){
            Ti.App.fireEvent('login.success',result.users[0],env);
        } else {
            Ti.App.fireEvent('login.failed',result,env);
        }
    });

})();

Alloy.Globals.Facebook = require('facebook');


var T = function (name) { 
    return require('T/' + name); 
};

T('trimethyl');

var Notifications = T('notifications');
Notifications.onReceived = function(e) {
    console.log("onreceived "+JSON.stringify(e));
    alert(e.data);
};
Notifications.subscribe();
console.log("token "+Notifications.getRemoteDeviceUUID());

1 个答案:

答案 0 :(得分:0)

供将来参考。

我必须一步一步地逐个测试,一次只使用一个警报来查找导致应用程序崩溃的代码部分。

我确实发现2个单独的文件相互调用,如文件1中的require("file2")和文件2中的require("file1")。虽然我不知道为什么会出现此问题/错误/无论发生什么仅在分发ad-hoc模式下,而不是直接从计算机运行应用程序。