Skip to content

Commit

Permalink
Update 240729_Push_Notification_Console.md
Browse files Browse the repository at this point in the history
  • Loading branch information
leeari95 committed Jul 30, 2024
1 parent f4c1689 commit 36622d8
Showing 1 changed file with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 240729 Push Notification Console

ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ์†์‰ฝ๊ฒŒ ํ…Œ์ŠคํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•.


7์›” 29์ผ (์›”)


# ํ•™์Šต๋‚ด์šฉ

## Push Notification ์„ค์ •

> Notification Console์€ ์›น ์ธํ„ฐํŽ˜์ด์Šค์ด๋ฉฐ, ์žฅ์น˜ ํ† ํฐ๊ณผ ์ฑ„๋„์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ๋ชจ๋‘ ์ „์†กํ•  ์ˆ˜ ์žˆ๋‹ค.

1. ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
2. ์ƒ์„ฑ ํ›„ Capabilities > Push Notification ์ถ”๊ฐ€
![image](https://github.com/user-attachments/assets/bc16e604-f3a2-4e5e-baa7-93646a58cc88)

3. AppDelegate.swift ์ˆ˜์ •
```swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.reduce("") {
$0 + String(format: "%02X", $1)
}
print("Device Token:" + token)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print(error.localizedDescription)
}
```

4. ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆผ ๊ถŒํ•œ ์š”์ฒญํ•˜๊ธฐ
```swift
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge], completionHandler: {
didAllow,Error in

DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
})
```

5. ๋นŒ๋“œ ํ›„ ์ฝ˜์†”์— print ์ฐํžˆ๋Š” ๋””๋ฐ”์ด์Šค ํ† ํฐ์„ ์–ป์–ด์˜จ๋‹ค.
6. [Push Notification Console](https://icloud.developer.apple.com/dashboard/notifications)๋กœ ์ด๋™ ํ›„ ํ”„๋กœ์ ํŠธ ๋ฒˆ๋“ค ์•„์ด๋””๋ฅผ ์ฐพ๋Š”๋‹ค.
![image](https://github.com/user-attachments/assets/7c003f2e-c44a-4f19-985f-3bfecc3afcda)

7. Create New Notification์„ ๋ˆŒ๋Ÿฌ์„œ ํ…Œ์ŠคํŠธ ๊ฐ’์„ ์ฑ„์›Œ๋„ฃ์–ด์ค€๋‹ค.
![image](https://github.com/user-attachments/assets/f40bd37f-02b3-45fa-9695-841011744785)


#

* General
* Name: Test Notification์„ ๊ตฌ๋ถ„ํ•˜๋Š” ์ด๋ฆ„
* Environment: ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ ์ „์†ก๋จ์„ ์˜๋ฏธ.
* Device Token: Xcode์—์„œ ์•ฑ ์‹œ์ž‘ ์‹œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๋””๋ฐ”์ด์Šค ํ† ํฐ
* Request Headers
* apns-topic: ์•Œ๋ฆผ์„ ์ˆ˜์‹ ํ•˜๋Š” topic
* apns-push-type: ํ‘ธ์‹œ ํƒ€์ž…
* apns-expiration: ์•Œ๋ฆผ ์ „์†ก ๋งŒ๋ฃŒ์ผ
* apns-priority: ์ฆ‰์‹œ ์ „๋‹ฌ(10), ๋””๋ฐ”์ด์Šค ํŒŒ์›Œ ์ƒํƒœ์— ๋”ฐ๋ผ ๋ณด๋ƒ„(5), ๋””๋ฐ”์ด์Šค ํŒŒ์›Œ ์ƒํƒœ ์šฐ์„ ์‹œํ•˜๊ณ  ๋””๋ฐ”์ด์Šค ๊นจ์–ด๋‚จ ๋ฐฉ์ง€(1)
* Payload
* event: ์ด๋ฒคํŠธ ํƒ€์ž…
* content-state: ๋ผ์ด๋ธŒ ์•กํ‹ฐ๋น„ํ‹ฐ ์—…๋ฐ์ดํŠธ์— ํ•„์š”ํ•œ ์ƒํƒœ๊ฐ’
* timestamp: ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•œ ์‹œ๊ฐ„

#

ํ•„๋“œ๊ฐ’์„ ๋‹ค ์ฑ„์›Œ์ฃผ์—ˆ์œผ๋ฉด, send๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ๋ฉด ๋ฐ”๋กœ ํ‘ธ์‹œ๊ฐ€ ์ „์†ก๋œ๋‹ค.

ํ‘ธ์‹œ๊ฐ€ ์ „์†ก๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•˜๋ฉด ๋œ๋‹ค.
![](https://github.com/user-attachments/assets/ff2845ff-ad81-4c76-be9d-c8c91868fc62)

---


# ์ฐธ๊ณ  ๋งํฌ


- [https://developer.apple.com/documentation/usernotifications/testing-notifications-using-the-push-notification-console](https://developer.apple.com/documentation/usernotifications/testing-notifications-using-the-push-notification-console)

0 comments on commit 36622d8

Please sign in to comment.