Migration iOS KakaoOpenSDK to KakaoSDKShare

Lee young-jun
4 min readMay 16, 2023

--

In a long time, I had to update one of my apps, ‘Where we go?’.
This app is using Government Open Data API and one of them was updated. So I had to migrate to version in 3 month.

With the migration I tried to upgrade Pods libraries before publishing. However I encountered this error.

curl: (22) The requested URL returned error: 404 Not Found

This error caused by deprecation of Kakao SDK Version 1, therefore I had to migrate it to Version 2.

My app is using only KakaoLink feature.
To use this of Version 2, I had to install KakaoSDKShare instead of KakaoOpenSDK.

And I modified project and codes like below.

API Key

to

KakaoSDK.initSDK(appKey: "...")

Info Plist

to

Framework

replace import statements

import KakaoLink
import KakaoMessageTemplate

to

import KakaoSDKShare
import KakaoSDKTemplate

Link

Replace statement to create Link

let kakaoLink = KMTLinkObject();
kakaoLink.androidExecutionParams = "param1&value1..."
kakaoLink.iosExecutionParams = "param1&value1..."

to

let kakaoLink = Link.init(androidExecutionParams: ["param1": value1, ...],
iosExecutionParams: ["param1": value1, ...]);

Text

var kakaoText : KMTTextTemplate!;
kakaoText = KMTTextTemplate.init(text: "..."),
link: kakaoLink);

to

var kakaoText : TextTemplate!;
kakaoText = TextTemplate.init(text: "...", link: kakaoLink)

Text with Button

var kakaoText : KMTTextTemplate!;
kakaoText = KMTTextTemplate.init(text: "..."),
link: kakaoLink)
kakaoText.buttons = [KMTButtonObject(builderBlock: { (buttonBuilder) in
buttonBuilder.link = KMTLinkObject(builderBlock: { (linkBuilder) in
linkBuilder.webURL = ...;
linkBuilder.iosExecutionParams = ...;
linkBuilder.androidExecutionParams = ...;
})
buttonBuilder.title = "앱으로 열기";
})];

to

var kakaoText : TextTemplate!;
kakaoText = TextTemplate.init(text: "...",
link: kakaoLink,
buttonTitle: "앱으로 열기"
buttons: [Button.init(title: "앱으로 열기",
link: kakaoLink)]);

Content

var kakaoContent : KMTContentObject!;
kakaoContent = KMTContentObject(title: "...", imageURL: image, link: kakaoLink);
kakaoContent.imageWidth = 120;
kakaoContent.imageHeight = 1;
kakaoContent.desc = "\(self.primaryAddr ?? "") \(self.detailAddr ?? "")\n"

to

var kakaoContent : Content!;
kakaoContent = Content.init(title: "...",
imageUrl: image,
imageWidth: 120,
imageHeight: 1,
description: "...", link: kakaoLink)

FeedTemplate

var kakaoFeed : KMTFeedTemplate!;
kakaoFeed = KMTFeedTemplate.init(builderBlock: { (kakaoBuilder) in
kakaoBuilder.content = kakaoContent;
kakaoBuilder.addButton(KMTButtonObject(builderBlock: { (buttonBuilder) in
buttonBuilder.link = KMTLinkObject(builderBlock: { (linkBuilder) in
linkBuilder.iosExecutionParams = ...;
linkBuilder.androidExecutionParams = ...;
})
buttonBuilder.title = "앱으로 열기";
}));

to

var kakaoFeed : FeedTemplate!;
kakaoFeed = FeedTemplate.init(content: kakaoContent,
buttons: [Button.init(title: "앱으로 열기",
link: kakaoLink)])

sendDefault

KLKTalkLinkCenter.shared().sendDefault(with: kakaoTemplate, success: { (warn, args) in
...
}, failure: { (error) in
...
})

to

ShareApi.shared.shareDefault(templatable: kakaoFeed) { result, error in
guard let result = result else {
...
return
}

UIApplication.shared.open(result.url)
...
}

If KakaoTalk not installed

guard ShareApi.isKakaoTalkSharingAvailable() else {
guard let kakaoWebUrl = ShareApi.shared.makeDefaultUrl(templatable: kakaoTemplate) else { return }
UIApplication.shared.open(kakaoWebUrl)
return
}

Troubleshootings

initSDK(appKey:) must be initialized.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
KakaoSDK.initSDK(appKey: key)
...
}

app does not have DOMAIN_CHECK_PASS permission

app does not have CUSTOM_EXECUTE_URL permission

Adds missed platform(Android or iOS)

Message shared with KakaoTalk

References

--

--

No responses yet