Carlos7560851
Posts: 0
Joined: Fri May 29, 2015 8:46 pm

Adding a disclaimer or accept terms at start of app but only once

Adding a disclaimer or accept terms at start of app but only once.

I found this code to do this but I dont know how to add it to appery

NSString *myString = [[NSUserDefaults standardUserDefaults] stringForKey:@"DidShowDisclaimer"]

if ([myString iEqualToString:@"YES"]) {
//show the view controller and once they have accepted save this key
[[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"DidShowDisclaimer"];
[[NSUserDefaults standardUserDefaults] synchronize]; //next time when the app is launched it will never execute this if condition
}

Any direction would be greatly appreciated :)

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Adding a disclaimer or accept terms at start of app but only once

Hi Carlos -

This code looks like Objective-C, in Appery.io we are working with JavaScript.

Here is a code that can give a basic idea -- you need to make a flag variable and check its value, and after first iteration make this flag value true:

pre
code
var afterLoad = localStorage.getItem("afterLoad");
if(!afterLoad)
alert("Message that will be shown only once!");
localStorage.setItem("afterLoad", "true");
/code
/pre

Carlos7560851
Posts: 0
Joined: Fri May 29, 2015 8:46 pm

Adding a disclaimer or accept terms at start of app but only once

Thank you Stepanov

Ill try it out and let you know.

josh
Posts: 0
Joined: Mon Jul 13, 2015 3:22 pm

Adding a disclaimer or accept terms at start of app but only once

Carlos,
I am getting ready to do the same for my app, did the code above work for you? What other changes did you have to make? Any tips/tricks/lessons learned from going through it? I am not a developer so any help you can offer would be greatly appreciated.
Thanks!
Josh

josh
Posts: 0
Joined: Mon Jul 13, 2015 3:22 pm

Adding a disclaimer or accept terms at start of app but only once

Illya,
Could you please describe how to make a flag variable in Appery.io?

I want to have the initial page be the disclaimer with an Agree button and Do Not Agree button. Would I put the JavaScript above in the event-run javascript for the "Agree" button? Or do I need to do something else?

Thanks in advance!
Josh

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Adding a disclaimer or accept terms at start of app but only once

Hi Josh -

The above code actually is making, so called "flag" local storage variable with name "afterLoad" on the 1st line it's initialized, but has value "null" if you will try to check it's value on the first line.
After that on lines 2 and 3 there is an 'if' statement which makes a checking is variable "afterLoad" is true or "not true" and after that shows alert message, that based on all above conditions will be shown only once.
And on line 4 we're assigning value "true" to our variable "afterLoad".

In your case the screen with disclaimer or the pop-up window, should be in place where alert message is, but you also would need to check the user choice that was made whether he agree or not.

josh
Posts: 0
Joined: Mon Jul 13, 2015 3:22 pm

Adding a disclaimer or accept terms at start of app but only once

Illya,
Thank you so much for your reply!

I added this under my JavaScript folder in my project and is working nicely, but I'm trying to do something a little different. I've been trying to modify it to do what I want for the past hour but am still having trouble.

What I'm really hoping to do is have a distinct 'Disclaimer' page in my project that would have my disclaimer text, an Agree button, a Disagree button and that would only display on the initial load of the app, and once they click Agree, would not display again and would navigate to the Main Menu, and if they hit Disagree, the app would close or display some sort of message that they can't continue until they agree.

Could you please describe how I can do this in my Appery.io project?

Thanks so much!
Josh

josh
Posts: 0
Joined: Mon Jul 13, 2015 3:22 pm

Adding a disclaimer or accept terms at start of app but only once

Hey Illya,
Any other thoughts on this?

I guess the two things I'd really like to accomplish that I can't with an Alert is:
1 - Basic formatting of disclaimer text (i.e. Bold, Italic, Underline)
2 - Ability to define the text in the button. Alert's just show up with an "OK" button which is more of acknowledgment than agreement/acceptance, so I really want a button that says "Agree" so that it's very clear to the user what they're doing.

Thanks for the help,
Josh

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Adding a disclaimer or accept terms at start of app but only once

Dear Josh,

This can be done but requires custom coding, which is outside the scope of our standard support.
Probably someone from community can share solution.

Also you may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack (http://appery.io/services/#Advisory_Pack).

Return to “Issues”