How to integrate Skype in my iPhone application

醉酒当歌 提交于 2019-11-29 14:54:43

Here is your swift code:

Swift

@IBAction func skypeMe(sender: AnyObject) {

    let installed = UIApplication.sharedApplication().canOpenURL(NSURL(string: "skype:")!)
    if installed {
        UIApplication.sharedApplication().openURL(NSURL(string: "skype:echo123?call")!)

    } else {

        UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/in/app/skype/id304878510?mt=8")!)
    }
}

Objective-C

- (IBAction)skypeMe:(id)sender {

    BOOL installed = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"skype:"]];
    if(installed){

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"skype:echo123?call"]];
    } else {

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/in/app/skype/id304878510?mt=8"]];
    }
}

I have changed skype URL for iTunes in this code and tested it with device and both URL is working fine.

For Swift 3.0 It opens itunes url if it is not installed, otherwise it will open skype.

@IBAction func btnSkypeLinkPressed(_ sender : UIButton) {

    let installed = UIApplication.shared.canOpenURL(NSURL(string: "skype:")! as URL)
    if installed {
        UIApplication.shared.openURL(NSURL(string: "skype:skypeID")! as URL)

    } else {

        UIApplication.shared.openURL(NSURL(string: "https://itunes.apple.com/in/app/skype/id304878510?mt=8")! as URL)
    }
}

and in plist add:

<key>LSApplicationQueriesSchemes</key>
    <array>
    <string>skype</string>
    </array>

Hope it will work for swift users Thanks.

Ben

in addition to @Dharmesh's answer, in iOS9 you must add the application you want to query for 'canOpenUrl' to you plist, under LSApplicationQueriesSchemes key

see this answer: https://stackoverflow.com/a/30988328/1787109

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!