iOS ๊ธฐ์ด ์ค์
ํธ์๋ฉ์ธ์ง ๋ฐ์ก์ ์ํ iOS OS ์์ ํ์๋ก ์ค์ ํด ์ฃผ์ ์ผ ํ๋ ๊ฐ์ด๋์ ๋๋ค.
APNS ์ธ์ฆ์ ๋ฐ๊ธ
Firebase ์ฐ๋
๋ค์ Firebase console์์ ํ๋ก์ ํธ ๊ฐ์ ์ค๋ฅธ์ชฝ์ setting ์์ด์ฝ์ ํด๋ฆญํ์ฌ ํ๋ก์ ํธ ์ค์ ์ผ๋ก ๋ค์ด๊ฐ๋๋ค.
ํด๋ผ์ฐ๋ ๋ฉ์์ง ๋ฉ๋ด๋ฅผ ํด๋ฆญํ์ฌ ๋ค์๊ณผ ๊ฐ์ด ๋ฐ๊ธ๋ฐ์ APN ์ธ์ฆ (.p8) ํค๋ฅผ ์ ๋ก๋ ํฉ๋๋ค.
Firebase console ํด๋ผ์ฐ๋๋ฉ์์ง ์ค์ ํ๋ฉด์์ APNS Authentication Key (APN ์ธ์ฆํค), APNS Certificates(APN์ธ์ฆ์) ์ ๋ก๋ 2๊ฐ์ง ์ค์ ์ ํ์ธํ ์ ์์ต๋๋ค.
์ฌ๊ธฐ์ Apple ์์ ๋ฐ๊ธ๋ฐ์ Key ๋๋ Certificates๋ฅผ ๋ฃ์ด์ผ๋ง ์๊ฒฉ ํธ์๊ฐ ์ ์์ ์ผ๋ก ์๋ํ๋ฉฐ, ๋ ์ค ํ๋๋ง ์ ๋ก๋ ํ์ฌ๋ ๋ฉ๋๋ค.
APNS Key : .p8 ํํ๋ฅผ ๋๊ณ ํ๋๋ง ์ ๋ก๋.
APNS Certificates : .p12 ํํ๋ฅผ ๋๊ณ ๊ฐ๋ฐ์ฉ, ๋ฐฐํฌ์ฉ ์ธ์ฆ์๊ฐ ๋ฐ๋ก ์กด์ฌ. ์ผ๋ ๋ง๋ค ๊ฐฑ์ ํ์.
*์์ด์ฆํธ๋์ปค ๋ํ๋จผํธ๋ .p8 ์ ๋ก๋๋ฅผ ๊ธฐ์ค์ผ๋ก ์์ฑ๋์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ Firebase ๊ตฌ์ฑ ํ์ผ๋ Xcode ๋ฃจํธ์ ๋ณต์ฌํฉ๋๋ค.
๋์๋ณด๋ ์ค์
์์ด์ฆํธ๋์ปค ๋์๋ณด๋์์ ํธ์ ์ฐ๋์ ์ํ ์ค์ ์ ์งํํฉ๋๋ค.
์๋น์ค์ค์ > ์ดํ๋ฆฌ์ผ์ด์ ์ค์ > ํธ์์ฐ๋ ๋ฉ๋ด๋ฅผ ํด๋ฆญํฉ๋๋ค.
์๋ ์ด๋ฏธ์ง์์ ํธ์ ์๋น์ค ํ์ ์ Firebase Cloud Messaging ์ผ๋ก ์ ํ ํ Android ํธ์ ์ฐ๋์ ์ถ๊ฐํ Firebase Admin SDK์ฉ "private key" ํ์ผ์ ์ถ๊ฐ ํด ์ฃผ์ธ์.
SDK ์ค์น
Cocoapod์์ SDK ๋ค์ด๋ก๋
XCode ํ๋ก์ ํธ ํ์ผ์ค Podfile ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ด SDK์ FirebaseMessaging์ ์ถ๊ฐํฉ๋๋ค.
pod 'RW'
pod 'Firebase/Messaging' >>> Objective-C ์ ๊ฒฝ์ฐ ์ถ๊ฐ ํด ์ฃผ์ธ์.๊ธฐ์กด์ SDK๋ฅผ ํ๋ฒ ์ค์นํ ๊ฒฝ์ฐ์๋ ์ค์นํ SDK ๋ฒ์ ์ ํ์ํด์ผ ํ๋ ๊ฒฝ์ฐ๋ ์์ต๋๋ค. ์๋์ ๊ฐ์ด ์ค์นํ SDK๋ฒ์ ์ ๋ช ์์ ์ผ๋ก ํ์ํ๋ฉด ๋ฉ๋๋ค.
pod 'RW', '~> 1.1.57'Terminal
TerminalPodfile ์ ํด๋น๋ผ์ธ์ ์ถ๊ฐํ ํ Terminal ํ๋ก๊ทธ๋จ์ ์คํํ์ฌ ๋ค์์ ๋ช
๋ น์ ์ํํฉ๋๋ค.
pod installSDK ๋ฒ์ ์ ๋ฐ์ดํธ์ ๊ฒฝ์ฐ ๋ค์์ ๋ช ๋ น์ ์ํํฉ๋๋ค.
pod updateCocoapod ์ฌ์ฉํ์ง ์์ ๊ฒฝ์ฐ
SDK ํ์ผ์ URL์์ ๋ค์ด๋ก๋ ํฉ๋๋ค.
๋ค์ด๋ ํ์ผ์ ์์ถ ํด์ ํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ์ผ์ด ํ์ธ ๊ฐ๋ฅํ๊ณ ์ด์ค ์๋์ ์ ํ๋ 3๊ฐ์ ํ์ผ์ ๋ถ์ ๋์ ์ฑ ํ๋ก์ ํธ์ ์ถ๊ฐํฉ๋๋ค.
ํ๋ก์ ํธ ์ ํํ ๋ง์ฐ์ค ์ฐํด๋ฆญ, Add Files to ๋ฉ๋ด๋ฅผ ์ ํํฉ๋๋ค.
![]()
์์์ ๋ค์ด๋ก๋ ๋ฐ๊ณ , ์์ถ ํด์ ํ ํด๋์ ๋ค์ด๊ฐ์ ์๋์ ๊ฐ์ด ์ถ๊ฐ ๋์ ํ์ผ์ ์ ํํ๊ณ , ํ๋ฉด ์๋์ชฝ ์ค์ ์ ์กด์ฌํ๋ ๋ชจ๋ target์ ํฌํจ๋์๋์ง ํ์ธํ ์ถ๊ฐ ํ๋ฉด ๋ฉ๋๋ค.
BuildSetting ์ ์๋์ ๊ฐ์ด ์ค์ ์ ์ถ๊ฐํฉ๋๋ค.
xcode ๊ฐ 12.3 ์ดํ ๋ฒ์ ์ด๊ณ ๋น๋ ๊ณผ์ ์์ ์๋์ ์ ์ฌํ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๊ฒฝ์ฐ๊ฐ ์์ผ๋ฉฐ,
์์ ๊ฒฝ์ฐ์๋ ์๋์ ๊ฐ์ด ์ค์ ์ ํ๊ณ , ๋น๋๋ฅผ ํ๋ฉด๋ฉ๋๋ค.
CocoaPod์ ์ฌ์ฉํ์ง ์์๊ฒฝ์ฐ, Firebase ์๋ ์ค์ ์ ์๋์ Firebase ๊ณต์ document๋ฅผ ์ฐธ๊ณ ํ์ฌ ์๋์ผ๋ก ํ๋ก์ ํธ์ ์ถ๊ฐํด ์ฃผ์ธ์.
dotAuthorizationKey ๋ฑ๋ก
info.plist ํ์ผ์ Open As Source Code ๋ฐฉ์์ผ๋ก ์คํํ ํ, ์๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
<key>dotAuthorizationKey</key>
<dict>
<key>serviceNumber</key>
<string>xxxxx</string> >>> ์๋น์ค ๋ฒํธ ํ์ธ ํ ๋ณ๊ฒฝ
<key>expireDate</key>
<string>14</string>
<key>isDebug</key>
<string>true</string>
<key>isInstallRetention</key>
<string>true</string>
<key>isFingerPrint</key>
<string>true</string>
<key>accessToken</key>
<string></string>
<key>useMode</key>
<string>2</string>
</dict>์ถ๊ฐํ ์ฝ๋ ์ค serviceNumber์ value๋ฅผ ์ฌ๋ฐ๋ฅธ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.
์์ด์ฆํธ๋์ปค ๋์๋ณด๋์ ๋ก๊ทธ์ธํ์ฌ ์ค์ > ์๋น์ค์ค์ ๋ฉ๋ด์์ '์๋น์ค๋ฒํธ' ํญ๋ชฉ์ ๊ธฐ์ฌ๋ ์ซ์๋ฅผ ํ์ธ ํ ๋ณต์ฌํ์ฌ serviceNumber ๊ฐ์ ๋ณ๊ฒฝ ํด ์ฃผ์ธ์.

HTTP ํต์ ํ์ฉ
์ด ๋ด์ฉ์ Wisetracker ๊ธฐ๋ณธ SDK๊ฐ ์ด๋ฏธ ์ ์ฉ๋ ๊ฒฝ์ฐ์๋ ์๋ก ์ ์ฉํ ํ์๊ฐ ์์ต๋๋ค. ๋ฉ์์ง ์๋น์ค๋ง ์ด์ฉํ๋ ๊ฒฝ์ฐ ์ฐธ์กฐํด์ฃผ์ธ์.
httpํต์ ์ ํ์ฉํ๊ธฐ ์ํด NSAppTransportSecurity ๋ฅผ ์๋์ ๊ฐ์ด ์ถ๊ฐํฉ๋๋ค.
์ด์ ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก info.plist ํ์ผ์ Open As Source Code ๋ฐฉ์์ผ๋ก ์คํํ ํ, ์๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>"Push Notification" Capability ์ถ๊ฐ
์ฑ์ ํธ์๊ธฐ๋ฅ์ ์ถ๊ฐํฉ๋๋ค.
"Signing & Capabilities" ํญ์ ์ ํํ ํ ํ๋ฉด ์ผ์ชฝ์ "+ Capability"๋ฅผ ๋๋ฌ์ฃผ์ธ์.
"Capability"ํ๋ฉด์์ "Push Notification"๊ธฐ๋ฅ์ ๊ฒ์ํ์ฌ ์ ํํฉ๋๋ค.
Background Modes๋ ์์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๊ฒ์ ํ ์ถ๊ฐ ํด ์ค๋๋ค.
์ด๊ธฐํ
์ด๊ธฐํ ๋ฐฉ๋ฒ์ SceneDelegate ๊ฐ ์ค์ ๋ ๊ฒฝ์ฐ์ ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ค.
SceneDelegate๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฉด AppDelegate์์ ์ด๊ธฐํ์์ ์ ํ๊ณ , ๊ทธ๋ ์ง ์๊ณ SceneDelegate๋ฅผ ์ฌ์ฉํ๋ฉด SceneDelegate์์ ์ด ์์ ์ ํด์ผ ํฉ๋๋ค.
1. iOS13 ๋ฏธ๋ง (SceneDelegate ์์)
SceneDelegate ์์)AppDelegate์ didFinishLaunchingWithOptions ํจ์์ SDK๋ฅผ Initializationํ๊ธฐ ์ํ ์ฝ๋๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ ์ฉํฉ๋๋ค. SDK๊ฐ ์ ์์ ์ผ๋ก ์ด๊ธฐํ ๋์์ ๋ ์๋์ ๊ฐ์ ๊ธฐ๋ณธ ๋ถ์์ด ๊ฐ๋ฅํฉ๋๋ค.
์ฑ ์คํ ๋ฐ ๋ฐฉ๋ฌธ์, ์ผ/์ฃผ/์์์๋ฐฉ๋ฌธ์ ๋ฑ ๋ฐฉ๋ฌธ๊ณผ ๊ด๋ จ๋ ์งํ
ํต์ ์ฌ, ๋จ๋ง๊ธฐ, ๊ตญ๊ฐ ๋ฑ ๋ฐฉ๋ฌธ์์ ๋จ๋ง๊ธฐ ํ๊ฒฝ์ผ๋ก ๋ถํฐ ์ถ์ถ๋ ์ ์๋ ์งํ
import DOT
import Firebase
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
...
// ๋ฑ๋ก ํ ํฐ์ ์์ ํ๊ธฐ ์ํ SDK๊ตฌ์ฑ
FirebaseApp.configure()
// S: Wisetracker SDK init
DOT.initialization(launchOptions, application: application)
#if DEBUG
DOT.checkDebugMode(true)
#else
DOT.checkDebugMode(false)
#endif
// E: Wisetracker SDK init
}#import <DOT/DOT.h>
#import <Firebase.h>
...
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ๋ฑ๋ก ํ ํฐ์ ์์ ํ๊ธฐ ์ํ SDK๊ตฌ์ฑ
[FIRApp configure];
// S: Wisetracker SDK init
[DOT initialization:launchOptions application:application];
#ifdef DEBUG
[DOT checkDebugMode:true]
#else
[DOT checkDebugMode:false]
#endif
// E: Wisetracker SDK init
}DOT๊ฐ ์ฌ์ฉ๋๋ ๊ณณ์์๋ import DOT์ ํตํด import๊ฐ ํ์ํฉ๋๋ค.
2. iOS13 ์ด์ (SceneDelegate ์ฌ์ฉ)
SceneDelegate ์ฌ์ฉ)๐ iOS13 ์ด์์ด์ด๋ SceneDelegate๋ฅผ ์ฌ์ฉํ์ง ์์ ์๋ ์์ด์, ์ด ๋์๋ ์์ SceneDelegate๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ๋ฅผ ์ฐธ์กฐํ์ธ์.
SceneDelegate์ sceneDidBecomeActiveํจ์์ SDK๋ฅผ Initializationํ๊ธฐ ์ํ ์ฝ๋๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ ์ฉํฉ๋๋ค. SDK๊ฐ ์ ์์ ์ผ๋ก ์ด๊ธฐํ ๋์์ ๋ ์๋์ ๊ฐ์ ๊ธฐ๋ณธ ๋ถ์์ด ๊ฐ๋ฅํฉ๋๋ค.
์ฑ ์คํ ๋ฐ ๋ฐฉ๋ฌธ์, ์ผ/์ฃผ/์์์๋ฐฉ๋ฌธ์ ๋ฑ ๋ฐฉ๋ฌธ๊ณผ ๊ด๋ จ๋ ์งํ
ํต์ ์ฌ, ๋จ๋ง๊ธฐ, ๊ตญ๊ฐ ๋ฑ ๋ฐฉ๋ฌธ์์ ๋จ๋ง๊ธฐ ํ๊ฒฝ์ผ๋ก ๋ถํฐ ์ถ์ถ๋ ์ ์๋ ์งํ
import DOT
import Firebase
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
...
func sceneDidBecomeActive(_ scene: UIScene) {
// ๋ฑ๋ก ํ ํฐ์ ์์ ํ๊ธฐ ์ํ SDK๊ตฌ์ฑ
FirebaseApp.configure()
// =======================================================
// Wisetracker ๊ธฐ๋ณธ SDK๊ฐ ์ด๋ฏธ ์ ์ฉ๋ ๊ฒฝ์ฐ์๋ ์๋ก ์ ์ฉํ ํ์๊ฐ ์์ต๋๋ค.
// ๋ฉ์์ง ์๋น์ค๋ง ์ด์ฉํ๋ ๊ฒฝ์ฐ ์ฐธ์กฐํด์ฃผ์ธ์.
// =======================================================
// Start : Wisetracker SDK ํธ์ถ
DOT.initialization(nil, application: UIApplication.shared)
#if DEBUG
DOT.checkDebugMode(true)
#else
DOT.checkDebugMode(false)
#endif
// E: Wisetracker SDK init
}
...
}#import <DOT/DOT.h>
#import <Firebase.h>
@implementation SceneDelegate
...
- (void)sceneDidBecomeActive:(UIScene *)scene {
...
...
// ๋ฑ๋ก ํ ํฐ์ ์์ ํ๊ธฐ ์ํ SDK๊ตฌ์ฑ
[FIRApp configure];
// =======================================================
// Wisetracker ๊ธฐ๋ณธ SDK๊ฐ ์ด๋ฏธ ์ ์ฉ๋ ๊ฒฝ์ฐ์๋ ์๋ก ์ ์ฉํ ํ์๊ฐ ์์ต๋๋ค.
// ๋ฉ์์ง ์๋น์ค๋ง ์ด์ฉํ๋ ๊ฒฝ์ฐ ์ฐธ์กฐํด์ฃผ์ธ์.
// =======================================================
// Start : Wisetracker SDK ํธ์ถ
[DOT initialization:nil application:[UIApplication sharedApplication]];
#ifdef DEBUG
[DOT checkDebugMode:true]
#else
[DOT checkDebugMode:false]
#endif
// End : Wisetracker SDK ํธ์ถ
}
...
@endoBridge ํ์ผ ์ถ๊ฐ
๋ง์ง๋ง์ผ๋ก bridge ํจ์๋ค์ ํธ์ถ ํ ์ ์๊ฒ bridge ํ์ผ์ ์ถ๊ฐ ํฉ๋๋ค.
์ผ์ชฝ์ ์ฒ์ ํ๋ฌ๊ทธ์ธ ๋ค์ด๋ก๋์ ์๊ธด node_modules/DotReactNativeBridge/ios ํด๋ ํ์์ ์๋ bridgeํ์ผ์ ์์น์ด๋ฉฐ ํ์ผ์ ๋ณต์ฌํ ๋ค , ์ค๋ฅธ์ชฝ์ ๋ณด์ด๋ ํ ํ๋ก์ ํธ ํด๋์ /ํ๋ก์ ํธ๋ช /ios/ํ๋ก์ ํธ๋ช ๊ณผ ๋์ผํ ํด๋ ๊ฒฝ๋ก์ ๋ณต์ฌํ ๋ ๊ฐ์ bridge ํ์ผ์ ๋ถ์ฌ๋ฃ์ต๋๋ค.
Bridge ํ์ผ ์ถ๊ฐ ํ AppDelegate.mm ํ์ผ์ DotReactBridge *dotReactBridge๋ฅผ ์ถ๊ฐ ํด ์ค๋๋ค.
#import "DotReactBridge.h"
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
// If you'd like to export some custom RCTBridgeModules, add them here!
DotReactBridge *dotReactBridge = [DotReactBridge alloc];
return @[dotReactBridge];
}์ด๋ฏธ์ง ํธ์๋ฉ์์ง ์ ์ฉ (์ ํ์ฌํญ)
Notification Service Extension Target ์ถ๊ฐ
์ด๋ฏธ์ง๋ฅผ ํฌํจํ ํธ์๋ฉ์ธ๋ฅผ ์์ ๋ฐ๊ธฐ ์ํด ํ์ํฉ๋๋ค.
File - New - Target ๋ฉ๋ด์์ "Notification Service Extension"์ ์ ํํฉ๋๋ค.
Product Name์ ํ๊ฒ๋ช ์ ์ ๋ ฅํฉ๋๋ค. (์๋์์ Podfile์ target์ ์ถ๊ฐํ ๋ ์ฌ์ฉํ ํ๊ฒ๋ช ์ ๋๋ค)
์ถ๊ฐ ์๋ฃ ํ NotificationServiceExtension ํด๋๊ฐ ์์ฑ๋ฉ๋๋ค.

Podfile ์์
Podfile์ ์๋์ ๊ฐ์ด ์ฑ์ ํ๊ฒ ์์ ์ด๋ฏธ์ง ํธ์๋ฅผ ์ํ ํ๊ฒ์ ์ถ๊ฐํ ํ pod install ๋ช
๋ น์ด๋ฅผ ์คํ์์ผ ์ค๋๋ค.
Podfile
Podfileโ๏ธํ๋ ์์ํฌ ์ถ๊ฐ์ ์ฑ์ ํ๋ ์์ํฌ ๋ฐฉ์๊ณผ ๋์ผํ๊ฒ ์์ฑ๋ ์ ์๋๋ก ํ๋ฒ ๋ ์ฒดํฌ ํด ์ฃผ์ธ์. (๋์ or ์ ์ )
โ๏ธWisetracker SDK ๋ฒ์ ์ด ๋ช ์๋์ด ์๋ค๋ฉด, ๋์ผํ๊ฒ ๋ฒ์ ์ด ๋ช ์๋์ด ์๋ ํํ๋ก ์ถ๊ฐํ๋์ง ์ฒดํฌ ํด ์ฃผ์ธ์.
target 'wisetracker' do
...
# S: Wisetracker SDK add
pod 'RW', '~> 1.1.45'
pod 'Firebase/Messaging'
# E: Wisetracker SDK add
...
# =======================================================
#Start : ์ด๋ฏธ์ง ํธ์ ์์ ์ ์ํ ์ถ๊ฐ
#=======================================================
target โNotificationServiceExtensionโ do
# ํ๋ ์์ํฌ๋ฅผ ๋์ ์ผ๋ก ๋งํฌํ๋๊ฒ์ด ๊ถ์ฅ๋์ค๋, ์ฑ์ ๋ฐ๋ผ ์ ์ ์ผ๋ก ๋งํฌํ๋ ๊ฒฝ์ฐ,
# ์ฑ์ ํ๋ ์์ํฌ ๋งํฌ๋ฐฉ์๊ณผ ๋์ผํ๊ฒ ์ฌ์ฉ ํด ์ฃผ์ธ์. ์๋์ ๋ฐฉ์์ ์ ์ ์ผ๋ก ๋งํฌํ๋ ๊ฒฝ์ฐ์
๋๋ค.
# use_frameworks! >>>>>>>>> ๋์ ์ ๊ฒฝ์ฐ์ผ๋ ์ฌ์ฉ
use_frameworks! :linkage => :static
# Wisetracker SDK ์ ๋ฒ์ ์ด ๋ช
์๋์ด ์๋ ๊ฒฝ์ฐ ๋์ผํ๊ฒ ๋ฒ์ ์ ๋ช
์ ํด ์ฃผ์ธ์.
pod 'RW', '~> 1.1.45'
pod โFirebaseMessagingโ, :modular_headers => true
end
#=======================================================
#End : ์ด๋ฏธ์ง ํธ์
#=======================================================
...
...
end์์ "NotificationServiceExtension"์ ๊ณ ๊ฐ์ฌ์์ ๋ง๋ ํ์ผ๋ช ์ผ๋ก ํด์ฃผ์ ์ผ ํฉ๋๋ค.
์์๋ ํ๊ฒ๋ช ์ด "NotificationServiceExtension"์ธ ๊ฒฝ์ฐ์ ๋๋ค.
๐ด Podfile์ ์ด๋ฏธ์ง ํธ์๋ฅผ ์ถ๊ฐํ์์ผ๋ ์๋์ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์๋๋ค๋ฉด ์๋์ ์ฑ ํ์ฅ ์ฝ๋๋ฅผ ์ถ๊ฐ ํด ์ฃผ์ธ์.
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
target 'wisetracker' do
...
post_install do |installer|
react_native_post_install(
installer,
...
...
)
...
############### App Extension ์๋ฌ ๋ฐ์์ ์ถ๊ฐ ######################
# ์ฑ ํ์ฅ์ด iOS ๊ธฐ๋ฅ๊ณผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์์ ๋กญ๊ฒ ์ก์ธ์คํ ์ ์๊ฒ ์ค์ .
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings[โAPPLICATION_EXTENSION_API_ONLYโ] = โNOโ
end
end
###################################################################
end
# S: Wisetracker SDK add
pod 'RW', '~> 1.1.45'
pod 'Firebase/Messaging'
# E: Wisetracker SDK add
...
...
endNotificationService ์์
NotificationServiceํ์ผ์ ์ด์ด ์๋์ ๋ด์ฉ์ผ๋ก ๋์ฒดํด ์ฃผ์ธ์. * ๊ธฐ์กด ๋ด์ฉ์ ๋ชจ๋ ์ญ์ ํ๊ณ ์๋ ๋ด์ฉ์ผ๋ก ๋์ฒดํ๋๊ฒ์ด๋ฉฐ, ์ถ๊ฐ๊ฐ ์๋์ ์ ์ ํด ์ฃผ์ธ์.
NotificationService
// =======================================================
// Start : ์์ค์ฝ๋ ๋ชจ๋ ๋ฐ๊พธ๊ธฐ
// =======================================================
import UserNotifications
import FirebaseMessaging
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent
if let bestAttemptContent = self.bestAttemptContent {
// DOT didReceiveNotificationExtensionRequest ๋ฉ์๋ ํธ์ถ
self.bestAttemptContent = self.didReceiveNotificationExtensionRequest(request, withContent: bestAttemptContent)
if let contentHandler = self.contentHandler {
FIRMessagingExtensionHelper().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
}
}
}
override func serviceExtensionTimeWillExpire() {
if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
func didReceiveNotificationExtensionRequest(_ request: UNNotificationRequest, withContent content: UNMutableNotificationContent) -> UNMutableNotificationContent {
return content
}
}
// =======================================================
// End : ์์ค์ฝ๋ ๋ชจ๋ ๋ฐ๊พธ๊ธฐ
// =======================================================// =======================================================
// Start : ์์ค์ฝ๋ ๋ชจ๋ ๋ฐ๊พธ๊ธฐ
// =======================================================
#import "NotificationService.h"
#import <DOT/DOT.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
self.bestAttemptContent = [DOT didReceiveNotificationExtensionRequest:request withContent:self.bestAttemptContent];
[[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent withContentHandler:self.contentHandler];
}
- (void)serviceExtensionTimeWillExpire {
self.contentHandler(self.bestAttemptContent);
}
@end
// =======================================================
// End : ์์ค์ฝ๋ ๋ชจ๋ ๋ฐ๊พธ๊ธฐ
// =======================================================
๐ด NotificationService ํ์ผ์์FirebaseMessaging ๋ชจ๋์ด ์๋ค๋ ์๋ฌ ๋ฐ์์ Notification Service Extension ํ๊ฒ์ ๋น๋ ์ค์ ์์ "Header Search Paths" ํญ๋ชฉ์ ํ์ธํ๊ณ Firebase Messaging ํค๋ ํ์ผ์ด ํฌํจ๋ ๋๋ ํ ๋ฆฌ๊ฐ ์๋์ง ํ์ธํ์ธ์.
![]()
iOS ๊ธฐ์ด์ค์ ์ ์๋ฃํ์ จ์ต๋๋ค ๐
๋ค์์ผ๋ก ํธ์๋ฉ์ธ์ง ์ค์ ์ ์ํ ๋จ๊ณ๋ฅผ ์งํ ํด ์ฃผ์ธ์ ๐๐ป
Last updated
Was this helpful?