Method of jump to mobile Taobao tmall in IOS application



When we do IOS development, we often encounter the function of opening other apps. This paper mainly introduces the relevant content about IOS implementation of jump to mobile phone Taobao tmall, and share it for your reference and learning. Let’s have a look at the detailed introduction together.

info.plist It needs to be added in (if the measured data is not filled in, it will not be judged whether the app is installed)

The code is as follows:

Click event of button to jump:

func copyStrKey(_ sender: UIButton) {
  let pboard = UIPasteboard.general
  pboard.string = self.productModel["search_key"].stringValue  
  var titleStr = ""
  var jumpStr = ""
  if sender.tag == 0 {
   Titlestr = "keyword copied successfully, do you want to jump to mobile Taobao app? "
   jumpStr = ("taobao://" + self.productModel["search_key"].stringValue).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
  } else if sender.tag == 1 {
   Titlestr: "Taobao password copied successfully, do you want to jump to mobile Taobao app? "
   jumpStr = "taobao://"
  let alertCtr = UIAlertController.init(title: titleStr, message: nil, preferredStyle: UIAlertControllerStyle.alert)
  alertCtr.addAction ( UIAlertAction.init (Title: "Cancel", style: UIAlertActionStyle.cancel , handler: nil))
  alertCtr.addAction ( UIAlertAction.init (Title: "OK", style: UIAlertActionStyle.default , handler: { (action) in   
   if let url = URL.init(string: jumpStr) {    
    if UIApplication.shared.canOpenURL(url) == true {
    } else {     
     let alertC =  UIAlertController.init (Title: "you have not installed the mobile Taobao app, would you like to go to the app store to download and install? ", message: nil, preferredStyle: UI AlertControllerStyle.alert )     
     alertC.addAction ( UIAlertAction.init (Title: "Cancel", style: UIAlertActionStyle.cancel , handler: nil))
     alertC.addAction ( UIAlertAction.init (Title: "OK", style: UIAlertActionStyle.default , handler: { (action: UIAlertAction) in      
      let AppStoreVC = UIViewController.init()      AppStoreVC.modalTransitionStyle = UIModalTransitionStyle.coverVertical
      let webView = UIWebView.init(frame: AppStoreVC.view.bounds)
      let request =  NSURLRequest.init (url:  URL.init (string: "itms- apps:// ")! // app store mobile Taobao address
      webView.loadRequest(request as URLRequest)
      self.present(AppStoreVC, animated: true, completion: {
       AppStoreVC.dismiss(animated: true, completion: nil)
     self.present(alertC, animated: true, completion: nil)     
  self.present(alertCtr, animated: true, completion: nil)


A URL cannot contain an ASCII character set and is not a character that must be escaped.

Use stringbyaddingpercentencodingwithallowedcharacters

Character set urlquerylallowedcharacterset

Jump to tmall:

1. Home page


2. Details (ID required)


3. Search list



The above is the whole content of this article, I hope that the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message and exchange, thank you for your support to developeppaer.

Recommended Today

Queue chain storage

Linked list realizes queue Create three files: queuelinked. H, queuelinked. C, queuelinkedtest. C queueLinked.h #ifndef QUEUE_LINKED_H_ #define QUEUE_LINKED_H_ #ifdef __GNUC__ #define DEPRECATED __attribute__( (deprecated) ) #elif defined(_MSC_VER) #define DEPRECATED __declspec( deprecated ) #else #define DEPRECATED #endif #ifndef PTOI #define PTOI( p ) ((int32_t)(int64_t)(p)) #endif #ifndef ITOP #define ITOP( i ) ((void *)(int64_t)(i)) #endif #define ADT […]