콘텐츠로 건너뛰기

Mac OS X

SDK 다운로드
샘플 프로젝트
SDK API 문서

Pushwoosh.framework 연결하기

Anchor link to

podfile 또는 cartfile에 다음 줄을 추가하여 종속성 관리자를 통해 Pushwoosh.framework를 프로젝트에 추가합니다:

platform :osx, '10.7'
target 'MyApp' do
pod 'Pushwoosh_mac'
end

또는 프로젝트의 Build Phases에 있는 Link Binaries With Libraries로 프레임워크를 드래그 앤 드롭할 수도 있습니다.

라이브러리 추가하기

Anchor link to

프로젝트의 Build Phases 탭에서 Link Binaries With Libraries를 열고 항목 추가(”+”) 버튼을 클릭합니다. libz.tbdlibc++.tbd 라이브러리를 검색하여 프로젝트에 추가합니다:

Pushwoosh Control Panel과 앱 연결하기

Anchor link to

Info.plist에서 문자열 유형의 키 Pushwoosh_APPID를 추가하고 값으로 Pushwoosh Application Code를 입력합니다.

AppDelegate 수정하기

Anchor link to

AppDelegate에 다음 코드를 추가합니다:

import PushKit
import Pushwoosh
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
//초기화 코드
//-----------PUSHWOOSH 부분-----------
NSUserNotificationCenter.default.delegate = Pushwoosh.sharedInstance()?.notificationCenterDelegateProxy
// 푸시 처리를 위한 커스텀 델리게이트 설정, 여기서는 뷰 컨트롤러
Pushwoosh.sharedInstance().delegate = self
// 앱 시작 시 푸시 처리
Pushwoosh.sharedInstance().handlePushReceived(aNotification.userInfo)
// 푸시 알림 등록!
Pushwoosh.sharedInstance().registerForPushNotifications()

UIApplicationDelegate(위와 동일한 파일)에 다음 코드를 추가합니다.

// 시스템 푸시 알림 등록 성공 콜백, PWMessagingDelegate에 위임
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Pushwoosh.sharedInstance()?.handlePushRegistration(deviceToken)
}
// 시스템 푸시 알림 등록 오류 콜백, PWMessagingDelegate에 위임
func application(_ application: NSApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
Pushwoosh.sharedInstance()?.handlePushRegistrationFailure(error)
}

푸시 알림을 처리하려면 UIApplicationDelegate(세 단계 위와 동일한 파일)에 다음 함수를 추가합니다:

//이 이벤트는 푸시를 수신할 때 발생합니다
func pushwoosh(_ pushwoosh: Pushwoosh!, onMessageReceived message: PWMessage!) {
print("onMessageReceived: \(String(describing: message.payload))")
}
//이 이벤트는 사용자가 알림을 탭할 때 발생합니다
func pushwoosh(_ pushwoosh: Pushwoosh!, onMessageOpened message: PWMessage!) {
print("onMessageOpened: \(String(describing: message.payload))")
}

푸시 알림 활성화하기

Anchor link to

타겟의 Signing and Capabilities로 이동합니다. + Capability를 누르고 Push Notifications를 추가합니다.