Skip to content

Instantly share code, notes, and snippets.

@frank-dspeed
Last active November 7, 2016 13:44
Show Gist options
  • Save frank-dspeed/ebd3074028c4f59f6980ede75125655b to your computer and use it in GitHub Desktop.
Save frank-dspeed/ebd3074028c4f59f6980ede75125655b to your computer and use it in GitHub Desktop.

#start screen:

//on start inapp or other buy process

-> billing provider posts success to /api/inapp -> changes key to true

manual

-> admin posts data to /api/keys -> changes key to true or false or active

Flow:

1. App First Start Asks do you got a Key?
2. if yes user enter. it will not save until success
3. entered key gets checked via api/licenses?aid=1&key=key
4. returns true false active 
-> if true save key run the software
-> if false or active show buy dialog
-> if entered key is wrong simply say that.
-> if not GOT Key generate one via public api. /api/licenses?action=create

Key gets Activated for products bei admin or payment provider via api. inapp api changes status from true or false to active app checks on key enter if status active then it don't saves if is payed true saves

thats it.

START -> GOT KEY? -> YES -> ENTER -> Verify - > if true save key // because active will work for start not for save this works as install only once -> NO -> GENERATE AND SAVE don't ask GOT KEY any More START -> KEY -> Verify -> Verifyed -> Show App -> false -> Show Buy

Android

https://developer.android.com/training/volley/simple.html <- how to make a request CHECK WHEN YOU GOT KEY in shared-prefrences if key returns active if no Show Start Screen yes -> Show App IF RESPONSE -> true -> https://developer.android.com/training/basics/data-storage/shared-preferences.html <- how to read and write the valid key to the installation -> Show APP ELSE NOTHING!

IOS

http://stackoverflow.com/questions/19197448/how-to-save-data-in-ios <- Use the DataHolder.h Advice to store the key in the app and send it to the api via.

The Request:

NSString *getString = [NSString stringWithFormat:@"parameter=%@",yourvalue];
NSData *getData = [getString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *getLength = [NSString stringWithFormat:@"%d", [getData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

[request setURL:[NSURL URLWithString:@"https:yoururl"]];

[request setHTTPMethod:@"GET"];

[request setValue:postLength forHTTPHeaderField:@"Content-Length"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

[request setHTTPBody:getData];

self.urlConnection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];

NSAssert(self.urlConnection != nil, @"Failure to create URL connection.");

// show in the status bar that network activity is starting
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment