获取appcelerator钛窗口的用户访问次数

时间:2016-07-15 09:20:39

标签: ios count appcelerator

我正在使用ios应用程序,用户将登录到应用程序。我在一个屏幕上有多个屏幕我有一个要求是,如果用户第一次访问该屏幕,我需要显示说明屏幕。如果屏幕访问数量更多比一次不需要显示说明。

I need to store that screens count for each user separately how can we achieve this in appcelerator titanium

请事先帮助我。

3 个答案:

答案 0 :(得分:0)

当有人点击屏幕时,您可以使用打开焦点事件来接听:

  1. 如果这是一个已连接的应用,并且您在登录时下载了用户个人资料,则可以存储一个标志来表示tutorialSeen或类似内容。在窗口打开/焦点或

  2. 时检查此项
  3. 如果未连接或您想在本地存储,请将标志存储在用户配置文件下的Ti.App.Properties中。

  4. (你可以同样存储一个计数值,当它们点击屏幕时会递增,但由于你只是想要第一次捕获,我会选择a)捕获事件,b)检查属性,c)如果为false,设置为true并显示教程,d)如果为true,则跳过。)

    希望有所帮助!

答案 1 :(得分:0)

如果您的唯一目的是仅在用户首次登录应用时显示“指示”窗口,我认为您不需要存储用户访问次数。

你可以这样做:

someController.js

function onLoginSuccess() {
    // getInt() will return the value of INSTRUCTION_WINDOW property, you can name this property whatever you want. 
    // if this property does not exist, then it will return the value of the second parameter.
    var showInstruction = Ti.App.Properties.getInt("INSTRUCTION_WINDOW", 1);

    if (showInstruction) {
        Alloy.createController('instructionWindow').getView().open();   

    } else {
        Alloy.createController('nextWindow').getView().open();  
    }
}


// logout function can be anywhere
// remember to set the property to 1 if you want to show the instructions again after logout and then login.
function logout() {
    Ti.App.Properties.setInt("INSTRUCTION_WINDOW", 1);
}

instructionWindow.js

$.instructionWindow.addEventListener('open', function () {
    // after opening the instruction window, set this property to 0
    // so it won't be shown up the next time the already logged-in user opens the app
    Ti.App.Properties.setInt("INSTRUCTION_WINDOW", 0);
});

答案 2 :(得分:0)

  

首先设置nsuserdefaults值@“1”。

[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"showtheinstruction"];
[[NSUserDefaults standardUserDefaults] synchronize];
  

之后你必须比较这个字符串并显示指令信息。

NSString *str_savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"showtheinstruction"];

if (str_savedValue isEqualToString:@"1") {

// show the instruction window.
 }
else
{
// don't show the instruction window.
}