์๋ ํ์ธ์ Foma ์ ๋๋ค!
์ค๋์ ์์๊ทธ๋์ด๋ผ๋ ์๋น์ค๋ฅผ ์ด์ฉํด ํธ์ฌ์๋ฆผ์ ๊ตฌํํด๋ณผ๊ฒ์!
๋ฐ๋ก ์์ํ๊ฒ ์ต๋๋ค~
KeyChainAccess
๋จผ์ ํค์ฒด์ธ ์ ๊ทผ์ผ๋ก ๊ฐ์ ์ธ์ฆ ๊ธฐ๊ด์์ ์ธ์ฆ์๋ฅผ ์์ฒญํฉ๋๋ค.
์์ ์ ์ด๋ฉ์ผ ์ฃผ์๋ฅผ ์ ๋ ฅํ๊ณ ๋์คํฌ์ ์ ์ฅ๋จ์ ํด๋ฆญํ ๋ค ๊ณ์์ ๋๋ฌ์ฃผ์ธ์.
์ธ์ฆ์๋ฅผ ์ํ๋ ์ด๋ฆ์ผ๋ก ์ง์ ๋ค์ ์ ์ฅํด์ฃผ์ธ์!
์ด๋ ๊ฒ ํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ์ผ์ด ์๊ธธ๊ฑฐ์์!
Apple Developer
์ด์ ์ ํ ๊ฐ๋ฐ์ ์ฌ์ดํธ๋ก ์ด๋ํฉ๋๋ค.
๋ก๊ทธ์ธ - Apple
idmsa.apple.com
Certificates,Identifiers & Profiles๋ก ์ด๋ํด์ฃผ์ธ์.
์ผ์ชฝ ํญ์์ Identifiers๋ฅผ ํด๋ฆญํด์ฃผ์๊ณ Identifiers + ๋ฒํผ์ ๋๋ฌ์ค๋๋ค.
App IDs๋ฅผ ํด๋ฆญํด์ฃผ์๊ณ Continue๋ฅผ ๋๋ฌ์ฃผ์ธ์.
App์ ๋๋ฌ์ฃผ์๊ณ Continue๋ฅผ ๋๋ฌ์ฃผ์ธ์.
์ํ๋ ์ค๋ช ๊ณผ ํ๋ก์ ํธ์ Bundle ID๋ฅผ ์ ์ด์ค ๋ค ์๋๋ก ๋ด๋ฆฌ๋ฉด
์ฌ๋ฌ ๊ธฐ๋ฅ๋ค์ด ์๋๋ฐ ์ฐ๋ฆฌ๊ฐ ํ์ํ๊ฑด ํธ์ฌ ์๋ฆผ์ด๋๊น Push Notifications ๋ง ๋๋ฅด๊ณ Configure๋ฅผ ๋๋ฌ์ค๋๋ค.
๋ง์ง๋ง์ผ๋ก Register๋ฅผ ๋๋ฌ ์ฑ์ ๋ฑ๋ก์์ผ์ค๋๋ค.
์ด์ ๋ฑ๋ก๋ ์ฑ์ ํด๋ฆญํด์ฃผ์ธ์.
๋ฐ์ผ๋ก ์ญ ๋ด๋ฆฌ๋ฉด ์๋์ ๊ฐ์ด Push Notifications ์์ Edit ๋ฒํผ์ ๋๋ฌ์ค๋๋ค.
์์ ์์นํด์๋ Development SSL Certificate๋ฅผ Create ๋ฒํผ์ ๋๋ฌ ์์ฑํด์ค๋๋ค.
์๋์ ๊ฐ์ ํ๋ฉด์ด ๋ฐํ ๋ฐ Platform์ iOS๋ก ํด์ฃผ์๊ณ ๋ฐ์ Choose File์ ์์์ ๋ค์ด๋ฐ์๋์ ์ธ์ฆ์๋ฅผ ๊ณจ๋ผ์ค๋๋ค.
๊ทธ ๋ค์ Continue๋ฅผ ๋๋ฌ ๋ค์์ผ๋ก ๋์ด๊ฐ์ฃผ์๊ณ
๋ง์ง๋ง์ผ๋ก Download๋ฅผ ๋๋ฌ์ ๋ค์ด๋ก๋๋ฅผ ํด์ฃผ์ธ์.
๊ทธ ๋ค์ ํค์ฒด์ธ ์ก์ธ์ค๋ก ๊ฐ๋ฉด ์๋์ ๊ฐ์ด Development ์ธ์ฆ์๊ฐ ์๋ก ์๊ฒผ์ํ ๋ฐ ์ฌ๊ธฐ์ ์ค๋ฅธ์ชฝ ๋ง์ฐ์ค๋ฅผ ํด๋ฆญํ ๋ค
๋ด๋ณด๋ด๊ธฐ๋ฅผ ๋๋ฌ์ฃผ์ธ์.
๊ทธ๋ผ ์๋์ ๊ฐ์ด ์ธ์ฆ์ ํ์ผ์ ์ ์ฅํ ์ ์๋๋ฐ ์๋ ํ์ผ์ .p12๋ก ์ ํํด์ฃผ์๊ณ ์ ์ฅํด์ค๋๋ค. (์ด๋ฆ์ ์ํ์๋๊ฑฐ ์ฐ์ ๋ ๋ผ์!)
ํ์ผ์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ํด์ค ๋ค ํ์ธ์ ๋๋ฅด๊ณ
๋งฅ์์ ๋ก๊ทธ์ธํ ๋ ์ ๋ ฅํ๋ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์.
์ด๋ ๊ฒ ์ ์ฅํ๋ฉด ์๋์ ๊ฐ์ด p12 ํ์ผ์ด ์ ์ฅ๋ ๊ฑฐ์์!
์ด์ ๋ค์ ์ ํ ๋๋ฒจ๋กํผ ์ฌ์ดํธ๋ก ๊ฐ์ ์๊น Push Notifications Edit ๋ฒํผ์ ๋๋ฌ์ค๋๋ค.
๊ฑฐ๊ธฐ์ ์ด์ ์๋ Production SSL Certificate๋ฅผ ์์ฑํด์ฃผ์ธ์.
๋๊ฐ์ด Choose File์ ๋๋ฅด๊ณ ์๊น์ ๊ฐ์ด ์ธ์ฆ์๋ฅผ ๋๋ฅธ๋ค ๋ค์ด๋ก๋ ํด์ค๋๋ค.
๊ทธ๋ฆฌ๊ณ ํค์ฒด์ธ ์ก์ธ์ค๋ก ๊ฐ๋ฉด ๋ค์๊ณผ ๊ฐ์ด Development ์ธ์ฆ์๊ฐ ์๋ Apple Push Services ์ธ์ฆ์๊ฐ ์์๊ฑฐ์์
์ฌ๊ธฐ์ ๋ด๋ณด๋ด๊ธฐ ํด์ค๋๋ค. ํ์ง๋ง Development ์ธ์ฆ์์ ํท๊ฐ๋ฆฌ์๋ ์์ผ๋ ๋ค์ Prod๋ฅผ ๋ถ์ฌ์ค๋๋ค.
๊ทธ๋ฌ๋ฉด ์๋์ ๊ฐ์ด p12์ธ์ฆ์ ๋๊ฐ๊ฐ ์์๊ฑฐ์์.
์ด๋ ๊ฒ ํ์๋ฉด ์ฐ์ 1์ฐจ ์ธํ ์ ๋ชจ๋ ๋๋ด์ ๊ฒ๋๋ค!!
OneSignal
์ด์ OneSignal์ผ๋ก ์ด๋ํด์ ํ์๊ฐ์ ์ ํด์ฃผ์ธ์!
Customer Messaging Delivered | Send Mobile & Web Push Notifications,…
The world's leader for mobile push notifications, web push, SMS, email & in-app messaging. Trusted by 1 million+ developers to send billions of message per day.
onesignal.com
๊ทธ๋ฆฌ๊ณค New App/Website ๋ฒํผ์ ๋๋ฌ ์ดํ๋ฆฌ์ผ์ด์ ์ ์์ฑํด์ค๋๋ค.
์ฌ๊ธฐ์ ์ฑ์ด๋ฆ์ ์ ํ๊ณ Apple iOS๋ฅผ ํญํด์ฃผ์๊ณ ๋ค์์ผ๋ก ๋์ด๊ฐ๋๋ค.
์ฌ๊ธฐ์ ์๋ Choose File์ด ๋ณด์ผ๊ฑฐ์์.
๋๋ฌ์ฃผ์๊ณ ์๊น ๋ค์ด๋ฐ์๋์ p12 ๋๊ฐ์ ํ์ผ์ค Prod๋ผ๊ณ ์ด๋ฆ ๋ค์ ๋ถ์ธ ํ์ผ์ ์ถ๊ฐํด์ฃผ๊ณ p12 ํ์ผ ๋น๋ฐ๋ฒํธ ์ ๋ ฅ ํ Next๋ฅผ ๋๋ฌ์ฃผ์ธ์!
๊ทธ ๋ค์ Native iOS๋ฅผ ํด๋ฆญํด์ฃผ์๊ณ Next๋ฅผ ๋๋ฌ์ฃผ์ธ์.
์ฌ๊ธฐ์ ์ฑ ์์ด๋๊ฐ ๋ฐ๊ธ๋๋๋ฐ ์ ์ ์ฅํด์ฃผ์ธ์!
๊ทธ๋ฆฌ๊ณค save ๋ฒํผ์ ๋๋ฌ์ค๋๋ค.
Xcode
ํ๋ก์ ํธ์ TARGETS๋ก ์ด๋ํด์ Signing & Capabilities๋ก ์ด๋ํ์ ๋ค ์๋์ ์๋ +Capbility ๋ฒํผ์ ๋๋ฌ์
Background Modes์ Push Notifications๋ฅผ ์ถ๊ฐํด์ฃผ์ธ์!
๋ฐฑ๊ทธ๋ผ์ด๋ ๋ชจ๋์์๋ Remote notifications๋ฅผ ํด๋ฆญํด์ฃผ์ธ์.
๊ทธ ๋ค์ podํ์ผ๋ก ์ด๋ํด์ OneSignal์ ์ถ๊ฐํด์ค๋๋ค.
Podfile
pod 'OneSignal'
AppDelegate
์ฑ๋๋ฆฌ๊ฒ์ดํธ๋ก ์ด๋ํด์ ๋จผ์ OneSignal์ import ํด์ค๋๋ค.
import OneSignal
OSSubscriptionObserver๋ฅผ ์ฑํํด์ฃผ์ธ์.
@main
class AppDelegate: UIResponder, UIApplicationDelegate,OSSubscriptionObserver{
... }
์ ๋๋ฆฌ๊ฒ์ดํธ๋ฅผ ์ฑํํ์๋ฉด ์๋ ๋ฉ์๋๋ฅผ ์ถ๊ฐํด์ผ ํ ๊ฑฐ์์!
func onOSSubscriptionChanged(_ stateChanges: OSSubscriptionStateChanges) {...}
๊ทธ๋ฆฌ๊ณค didFinishLaunchingWithOptions ๋ฉ์๋๋ก ์ด๋ํ์ ์ ์๋์ ๊ฐ์ด ์ธํ ํด์ฃผ์ธ์.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
requestNotificationPermission()
OneSignal.add(self as OSSubscriptionObserver)
OneSignal.initWithLaunchOptions(launchOptions)
OneSignal.setAppId("์์๊ทธ๋์ฑ์์ด๋")
...
}
requestNotificationPermission ๋ฉ์๋๋ฅผ ๋ฐ๋ก ์ถ๊ฐํด์ค๋๋ค.
func requestNotificationPermission(){
UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.badge], completionHandler: {didAllow,Error in
if didAllow {
print("Push: ๊ถํ ํ์ฉ")
} else {
print("Push: ๊ถํ ๊ฑฐ๋ถ")
}
})
}
๊ทธ ๋ค์ ์ฑ์ ์คํ์์ผ์ฃผ๋๋ฐ์.
์ฃผ์ํ์ค ์ ์ ์๋ฎฌ๋ ์ดํฐ๊ฐ ์๋ ์ค์ ์์ดํฐ ๋๋ฐ์ด์ค๋ก ํด์ผํฉ๋๋ค. (์๋ฎฌ๋ ์ดํฐ์์ ํธ์ฌ์๋ฆผ์ด ์๋ฉ๋๋ค....)
๊ทธ ๋ค์์ผ๋ก ์๋ ํจ์๋ฅผ didFinishLaunchingWithOptions ๋ฐ์ ์ถ๊ฐํด์ค๋๋ค.
userID๋ ํ์ฌ ๋๋ฐ์ด์ค๋ฅผ ๊ฐ์ง ์ฌ๋์ ์์ด๋๊ฐ ๋ฉ๋๋ค.
OneSignal.promptForPushNotifications(userResponse: { accepted in
let userID = OneSignal.getDeviceState()!.userId
OneSignal.postNotification(["contents":["en":"์๋
ํ์ธ์!"],"ios_badgeType":"Increase","ios_badgeCount":"1","include_player_ids":[userID ?? ""]])
})
์ด๋ ๊ฒ ํ์๋ฉด ์๋์ ๊ฐ์ด ํธ์ฌ์๋๊ณผ ๋ฑ์ง์์ฑ์ด ๋๋๊ฑธ ๋ณผ ์ ์์ต๋๋ค!!
์ค๋์ ์ด๋ ๊ฒ OneSignal์ ์ด์ฉํด์ ํธ์ฌ์๋์ ๋ณด๋ด๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์์๋ณด์๋๋ฐ์.
ํน์๋ผ๋ ํ๋ฆฐ ์ ์ด ์๊ฑฐ๋ ๊ถ๊ธํ์ ๋ถ๋ถ์ด ์๋ค๋ฉด ๋๊ธ๋ก ์๋ ค์ฃผ์ธ์!
๋๊ธ