Thursday, 14 July 2016

Onclick Button calling with PhoneNumber in ios swift2

  1.  On click Button Call

    <***********Steps to create  calling Button**********>

    1. Add pies of code in info.plist

      </dict>
          <key>LSApplicationQueriesSchemes</key>
           <array>       
              <string>telprompt</string>
              <string>tel</string>
          </array>
      </dict>

    2. Add Button in Storyboard
    3.  Create An Button Action in View Controller 

      @IBAction func call(sender: AnyObject) {
      //Replace with your Phone Number
      UIApplication.sharedApplication().openURL(NSURL(string: "tel://1234567890")!)
      }

      <*******OR********>

      <***********Steps to create  calling Button with function**********>

    1. Add pies of code in info.plist 

      </dict>
          <key>LSApplicationQueriesSchemes</key>
           <array>       
              <string>telprompt</string>
              <string>tel</string>
          </array>
      </dict>

    2. Add Button in Storyboard
    3.  Create An Button Action in View Controller with callPhoneNumber Method.

      @IBAction func call(sender: AnyObject) { 
      //Replace with your Phone Number
      callPhoneNumber("1234567890")
      }
    4. Create Function with name callPhoneNumber() 

      private func callPhoneNumber(phoneNumber:String) {
              if let phoneCallURL:NSURL = NSURL(string: "tel://8050741946") {
                  let application:UIApplication = UIApplication.sharedApplication()
                  if (application.canOpenURL(phoneCallURL)) {
                      application.openURL(phoneCallURL);
                  }
              }
          }

       

    5. Finished Run and Check ......happy Coding


No comments:

Post a Comment