Is there a way to detect if a user completed a purchase on another website through a UIWebView in an IOS app?

StackOverflow https://stackoverflow.com/questions/23282916

  •  09-07-2023
  •  | 
  •  

Question

For example, I would forward the user to a product page on jcpenney.com in a uiwebview, and then the user will add it to the jcpenney.com and go through normally as if he/she were purchasing the product online.

Is there a way for me to know whether or not the user completed the purchase?

I was thinking something along the lines of parsing the html pages the user visits, and one might contain the "order complete" string or something along that manner.

Thanks!

Was it helpful?

Solution

If you know how the final page is, you can analyze it in some of the delegates methods of the WebView. For example implemeting something like this in the class that is the delegate of the WebView:

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent"];
    if ([myText rangeOfString:@"order complete"].location != NSNotFound) {
        //Your logic stuff
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top