Xcode is an ipad application. UIWebView

I am working on an application to run only the base camp.

I need it to work when you log in and click "Remember me on this computer"

I'm not sure how to configure it to actually remember your username and leave you on the system when you return to the application.

Is there a way to "save" the state of the application when you fully and return to what you are doing?

Here is an image of the website login form used in the application.

http://arikburns.com/forums/fn/IMG_0005.PNG

Thanks.

+4
source share
1 answer

If your web application uses url sessions, you can save your current url using the webview delegate:

- (void)webViewDidFinishLoad:(UIWebView *)myWebView { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:myWebView.request.URL.absoluteString forKey:@"lastUrl"]; [prefs synchronize]; } 

... and load it again from the settings when viewDidLoad:

 - (void)viewDidLoad { [super viewDidLoad]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: [prefs objectForKey:@"lastUrl"]]]]; } 

You can also access cookies with javascript if you need to save and set them:

 NSString *myCookies = [[myWebView stringByEvaluatingJavaScriptFromString:@"document.cookie"] copy]; 
+4
source

Source: https://habr.com/ru/post/1310597/


All Articles