【问题标题】:titanium iOS app for adhoc distribution stuck on splash screen用于临时分发的钛 iOS 应用程序卡在初始屏幕上
【发布时间】:2017-08-31 23:33:35
【问题描述】:

我正在运行一个钛合金 iOS 应用程序,当我从 appcelerator studio 运行它时,它在模拟器和设备上都可以正常工作,但是当我将应用程序打包以进行临时分发并通过 iTunes 将其安装在我的 iPhone 设备上时它只是卡在初始屏幕上。

我也无法调试,因为它是临时分发。我注意到使用警报的唯一一件事是它通过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());

【问题讨论】:

  • alloy.js & index.js的分享码sn-p
  • 如果您在 index.js 的最顶部放置一个日志,它会被记录吗?您还可以评论整个alloy.js,然后取消注释其中的一部分,以便它的哪一部分导致问题?也请使用日志而不是警报。
  • 我无法访问日志,这就是我尝试使用警报的原因。
  • 该应用程序是通过iTunes安装到iPhone上的,它与计算机完全断开连接,当我从计算机或模拟器运行它时,它运行良好。

标签: javascript ios titanium appcelerator


【解决方案1】:

供日后参考。

我必须一次又一次地使用单个警报逐块逐行测试,以找出导致应用程序崩溃的代码部分。

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

【讨论】:

    猜你喜欢
    • 2015-12-26
    • 2017-11-05
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 2018-07-16
    • 2012-11-05
    相关资源
    最近更新 更多