-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 240729_Push_Notification_Console.md
- Loading branch information
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
Sources/AriNote/TIL.docc/SwiftUI/240729_Push_Notification_Console.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |