OneSignal 설명서를 확인했지만 사용자가 알림과 상호 작용할 때 Swift를 사용하여 iOS Native SDK에서 게시물 알림의 추가 데이터 (예 : postID, userID, type)를 사전 설정하는 방법을 결정하고 리디렉션하는 방법을 명확하게 이해하지 못했습니다. 나는 단지 그렇게하고 있어요 게시신호 알림의 추가 데이터를 게시하고 수신하는 방법은 무엇입니까?
:
OneSignal.sendTag("username", value: "\(user)")
OneSignal.postNotification(["contents": ["en": "@\(user) added an additive to your '\(title)' experience: \"\(strLast)\""],
"include_player_ids": [postOwnerPlayerID],
수신 :
OneSignal.initWithLaunchOptions(launchOptions, appId: "______", handleNotificationReceived: nil, handleNotificationAction: {
(result) in
// This block gets called when the user reacts to a notification received
let payload = result?.notification.payload
//Try to fetch the action selected
if let additionalData = payload?.additionalData {
print("payload")
print(additionalData)
}
// After deciding which action then I can redirect user..
let username: String? = UserDefaults.standard.string(forKey: KEY_UID)
if username != nil {
if let tabbarController = self.window!.rootViewController as? UITabBarController {
tabbarController.selectedViewController = tabbarController.viewControllers?[2]
// NotificationCenter.default.post(name: Foundation.Notification.Name(rawValue: "notificationsUp"), object: nil)
}
}
}, settings: [kOSSettingsKeyInFocusDisplayOption : OSNotificationDisplayType.none.rawValue])
감사합니다! – sputn1k