Source language: Translate to:

How to close a NeoAppBuilder app ?

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

How to close a NeoAppBuilder app ?

Postby David de Argentina » Wed Mar 11, 2015 6:03 pm

hi all,

does any know how to close a NeoAppBuilder app ?

My program needs to be closed after use for security reasons.

If it remain active at the task manager, could be reopened, with some security issues.

Any ideas ?

Thanks in advance,

David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: How to close a NeoAppBuilder app ?

Postby Neosoft Support » Thu Mar 12, 2015 10:30 am

You can do this:

BeginJS
window.close();
EndJS

This will crash NeoAppBuilder's built-in browser/run simulator, so don't run it there. (This will be fixed in the next update.)
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: How to close a NeoAppBuilder app ?

Postby Gaev » Thu Mar 12, 2015 11:09 am

Dave:

Last night, I attached this code to a PushButton ... and when I clicked on the Button (when App was running in Firefox on my PC), nothing happened ... just thought you might want to investigate that too.

BTW, before I tried it, I did some Google searches ... and came across a number of posts where Google Support people "highly discouraged" closing/exiting any App on their mobile devices via script ... said that it would disrupt Android's automatic management of memory ... and could even cause crashes upon restart in some cases.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: How to close a NeoAppBuilder app ?

Postby luishp » Fri Mar 13, 2015 12:35 am

WebApps should not be closed programaticaly, as the browser control must be always on users hands.
If you need to restrict access for security reasons, you can control it through a password field.
I have tested it with NeoAppBuilder with success.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 357
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: How to close a NeoAppBuilder app ?

Postby David de Argentina » Fri Mar 13, 2015 8:59 am

Tanks Dave, Gaev & Luis.

My app is running on a mobile under Android 4.0.4.

All works fine.

the Dave suggestion:

Code: Select all
BeginJS
window.close();
EndJS


is not working. the debugger tells something like:

"Scripts may close only the windows that were opened by it. "


I think Dave could add a trick on the main app, in order to be available as option at the main configuration of the app.

On the other hand, I added a "Login" and "Logout" services, at the first statements of the app. This services works fine, but, i just discovered that the GoBack key of the phone is still working. After logout, any unauthorized person could "GoBack" the app, and could use the program.

I researched about this problem, and a possible solution is add, at the main app entry, a script like:

Code: Select all
<body onload=NoBack() ... >


being the NoBack() function something like:

Code: Select all
<script type "text/javascript">
history.go(1);
</script>


I didn't test this solution, because i need edit the main html after the compile is done, and is very dirty...

Perhaps Dave could add some like this as option at the App main configuration...

If any has another idea... i'm ready to test...

Greetings from Buenos Aires,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: How to close a NeoAppBuilder app ?

Postby Gaev » Fri Mar 13, 2015 9:45 am

David de Argentina:

1) You could test the jQuery event handler called .unload() ... http://api.jquery.com/unload/ ... to trap when an App is being exited by the user ... your code in this function could "mark the user as logged out".

2) If that works on the mobile devices, you could design your App such that every page-start event invokes a function like validateLogin() ... such a function can check "if the user is logged out" ... if not, ask him/her to re-Login.


Another idea would be to use a "heartbeat" technique ...

1) using a Javascript Timer, save the current time every (say) 5 seconds.

2) in the page-start event section, check this saved value ... if greater than (say) 6 seconds, consider user to be returning after exiting.

I have not checked this to determine if the Timer event code is "suspended" when the App is exited ... if it is not suspended, this idea would not work.


@Dave: in researching this, i noticed that there was no app-stop code section ... only an app-start section ... will there be support for this event in the future ?
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: How to close a NeoAppBuilder app ?

Postby Neosoft Support » Fri Mar 13, 2015 10:01 am

Last night, I attached this code to a PushButton ... and when I clicked on the Button (when App was running in Firefox on my PC), nothing happened.


FireFox doesn't allow an app to close itself, the best you can do is navigate away from your app which isn't a great solution. For example:

if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
//Firefox
var win=window.open("about:blank","_self");
win.close();
} else {
//Other browsers
window.close();
}

The close option works great with Chrome and IE so it may be useful in certain situations.

WebApps should not be closed programaticaly, as the browser control must be always on users hands.
If you need to restrict access for security reasons, you can control it through a password field.


I think you're right about that, but why can't mobile apps be closed? There are lots of times where I open an app, use it for one thing and then want to close it. Instead I have to take the extra step of opening the list of open apps and manually shutting them down. Leaving apps running uses resources and drains the battery.

On the other hand, I added a "Login" and "Logout" services, at the first statements of the app...


Interesting. Can you share the code you used to do this?

After logout, any unauthorized person could "GoBack" the app, and could use the program.


I'll look into this.

in researching this, i noticed that there was no app-stop code section ... only an app-start section ... will there be support for this event in the future ?


Yes, there will be a shutdown event in the future.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: How to close a NeoAppBuilder app ?

Postby David de Argentina » Fri Mar 13, 2015 10:31 am

On the other hand, I added a "Login" and "Logout" services, at the first statements of the app...

Interesting. Can you share the code you used to do this?


Login is a simple form that launch a php that validates user and pass. returns true, false or userID. Nothing special.

Logout resets user variables, and go to the login page.

Yes, there will be a shutdown event in the future.


Nice ! Nice ! Nice !

David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: How to close a NeoAppBuilder app ?

Postby luishp » Fri Mar 13, 2015 10:34 am

Take a look here, please:

http://sinlios.com/apps/passwordtest
Password: mypass

SourceCode:
http://sinlios.com/apps/passwordtest/password-test.neoapp

¿Is this what you are looking for?
It worked even better when page-enter event was onBeforeLoad on previous beta, pehaps would be interesting to keep both events.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 357
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: How to close a NeoAppBuilder app ?

Postby David de Argentina » Fri Mar 13, 2015 11:09 am

Thanks a bunch Luis !!!!

Simple and brilliant !
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: How to close a NeoAppBuilder app ?

Postby luishp » Fri Mar 13, 2015 10:51 pm

Great!! :-)
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 357
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: How to close a NeoAppBuilder app ?

Postby luishp » Sat Mar 14, 2015 6:00 am

I think you're right about that, but why can't mobile apps be closed? There are lots of times where I open an app, use it for one thing and then want to close it. Instead I have to take the extra step of opening the list of open apps and manually shutting them down. Leaving apps running uses resources and drains the battery.


This is quite annoying for me too, but i think it's just how user experience in designed on mobile devices. It is quite uncommon to find any close button on mobile apps, they usually just go to the home screen.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 357
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: How to close a NeoAppBuilder app ?

Postby Neosoft Support » Sat Mar 14, 2015 10:19 am

Thanks Luis!

It worked even better when page-enter event was onBeforeLoad on previous beta, perhaps would be interesting to keep both events.


OnBeforeLoad is a little tricky because the app hasn't been initialized yet, so some features are not available, but I'll see what's possible.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron