React-native-onesignal: libRCTOneSignal.a๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2018๋…„ 08์›” 16์ผ  ยท  26์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: OneSignal/react-native-onesignal

์„ค๋ช…:
๋‚˜๋Š” ์—ฌ๊ธฐ์—์„œ React Native SDK์— ๋Œ€ํ•œ ์ง€์นจ์„ ๋”ฐ๋ž์Šต๋‹ˆ๋‹ค - https://documentation.onesignal.com/docs/react-native-sdk-setup

npm ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  react-native link ๋ฐ pod install . ๋ชจ๋“  ๊ฒƒ์ด ์ˆœ์กฐ๋กญ๊ฒŒ ์ง„ํ–‰๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ ๋‹ค์Œ ์•Œ๋ฆผ ํ™•์žฅ ์ƒ์„ฑ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. Link Binary with Libararies ์„ค์ •์— libRCTOneSignal.a ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ผ๋Š” ์ง€์‹œ๋ฅผ ๋ฐ›์€ ๋ถ€๋ถ„์— ์ด๋ฅด๋ฉด Xcode๊ฐ€ ํ‘œ์‹œํ•˜๋Š” ๋ชฉ๋ก์—์„œ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. One Signal์„ ๊ฒ€์ƒ‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

screen shot 2018-08-16 at 12 55 02 pm

๋‚ด ํ—ค๋” ๊ฒ€์ƒ‰ ํŽ˜์ด์ง€ ์„ค์ •์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
screen shot 2018-08-16 at 12 55 26 pm

์ด์ œ libreact-native-onesignal.a ์ถ”๊ฐ€ํ•˜๋ ค๊ณ  ์‹œ๋„ํ–ˆ์ง€๋งŒ ๋นŒ๋“œํ•  ๋•Œ ๋‹ค์Œ ์—ฐ๊ฒฐ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

ld: library not found for -lreact-native-onesignal
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ํ™˜๊ฒฝ

  1. react-native-one-signal - 3.2.6
  2. RN - 0.55.4
  3. Xcode - 9.2
Help Wanted dependencies iOS

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

react-native link ๊ฐ€ ํ‰์†Œ์™€ ๊ฐ™์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์œผ๋กœ ๋‚˜ํƒ€๋‚ฌ์Šต๋‹ˆ๋‹ค. DI๋Š” RCTOneSignal ํ”„๋กœ์ ํŠธ๋ฅผ Libraries ์— ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•ด์•ผ ํ–ˆ๊ณ  ๊ทธ๋Ÿฐ ๋‹ค์Œ libRCTOneSignal.a ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ๋žŒ๋“ค์ด ๋งํฌ๊ฐ€ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก react-native link ์™ธ์— ์ˆ˜๋™ ๋งํฌ์— ๋Œ€ํ•œ ์ง€์นจ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. :)

๋ชจ๋“  26 ๋Œ“๊ธ€

react-native link ๊ฐ€ ํ‰์†Œ์™€ ๊ฐ™์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์œผ๋กœ ๋‚˜ํƒ€๋‚ฌ์Šต๋‹ˆ๋‹ค. DI๋Š” RCTOneSignal ํ”„๋กœ์ ํŠธ๋ฅผ Libraries ์— ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•ด์•ผ ํ–ˆ๊ณ  ๊ทธ๋Ÿฐ ๋‹ค์Œ libRCTOneSignal.a ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ๋žŒ๋“ค์ด ๋งํฌ๊ฐ€ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก react-native link ์™ธ์— ์ˆ˜๋™ ๋งํฌ์— ๋Œ€ํ•œ ์ง€์นจ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. :)

์–ด๋–ป๊ฒŒ ์ถ”๊ฐ€ํ–ˆ์–ด?

๋˜ํ•œ RCTOneSignal ํ”„๋กœ์ ํŠธ๋ฅผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •ํ™•ํžˆ ํŒŒ์•…ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

@nickyhajal @abdul-elah-js @steverob ๋ˆ„๊ตฐ๊ฐ€ RCTOneSignal ํ”„๋กœ์ ํŠธ๋ฅผ Libraries ์— ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

์ด ๋ฌธ์ œ๋Š” ๋ฌธ์„œ์—๋„ ๋‚˜์™€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

@pacozaa ์—ฌ๊ธฐ์—์„œ Facebook์˜ ์ง€์นจ์„ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: https://facebook.github.io/react-native/docs/linking-libraries-ios

node_modules/react-native-onesignal/ios๋ฅผ ์—ฐ ๋‹ค์Œ RCTOneSignal.xcodeproj๋ฅผ XCode ํ”„๋กœ์ ํŠธ ํด๋” Libraries์— ๋Œ์–ด๋‹ค ๋†“์œผ๋ฉด libRCTOneSignal.a๊ฐ€ ๊ฒ€์ƒ‰์— ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

screenshot at nov 30 16-21-30

์ด๊ฒƒ์„ ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•ด React-Native ์„ค์ •์˜ ๋ฌธ์„œ๋ฅผ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ์ œ๊ธฐํ•˜๊ณ  ๋ฌธ์„œ๋ฅผ ๊ฐœ์„ ํ•˜๋Š” ๋ฐ ๋„์›€์„ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํด๋”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

@rgomezp ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ œ๋ฅผ ๋‹ค์‹œ ์—ด์–ด์ฃผ์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? libRCTOneSignal.a๋Š” Xcode 12์˜ ํ™•์žฅ์—์„œ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Xcode 11.7์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

@์•Œ๋ ˆํ‚จ ์”จ ,
ios ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•˜์—ฌ pod deintegrate && pod install

์ด๊ฒƒ์€ Xcode 12์—์„œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํฌ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•,
์ด๊ฒƒ์€ Xcode 12๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  Cocoapods๋ฅผ ์‚ฌ์šฉํ•˜์ง€ _์•Š์€_ ์‚ฌ๋žŒ๋“ค์„ ์œ„ํ•œ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋ฅผ ์ถ”์ ํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์‹œ ์—ฝ๋‹ˆ๋‹ค.

๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ํฌ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  Xcode 12๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•. :(

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํฌ๋“œ๋กœ ์ด๋™ํ•ด์•ผ ํ–ˆ์ง€๋งŒ ๋‚ด ์Šคํ…Œ์ด์ง• ๋Œ€์ƒ์—์„œ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋นจ๋ฆฌ ๊ฒ€ํ† ํ•ด ์ฃผ์„ธ์š” ๐Ÿ™

@rgomezp ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ์—…๋ฐ์ดํŠธ๊ฐ€ ์žˆ์Šต๋‹ˆ๊นŒ? cocoapods๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ–ˆ์ง€๋งŒ ์–ด๋–ค ์ด์œ ๋กœ OneSignal์ด ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. React Native 0.59 ์‚ฌ์šฉ

react-native-onesignal ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ Pod์˜ ์˜ˆ์ž…๋‹ˆ๋‹ค.

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'



target 'example' do
  # Comment the next line if you don't want to use dynamic frameworks
  # Pods for example
  pod 'Branch', '0.28.1'
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
  pod 'React', :path => '../node_modules/react-native/'
end

target 'exampleDev' do
  # Comment the next line if you don't want to use dynamic frameworks
  # Pods for exampleDev
  pod 'Branch', '0.28.1'
  pod 'React', :path => '../node_modules/react-native/'
  pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
end

target 'OneSignalNotificationServiceExtension' do
  # Comment the next line if you don't want to use dynamic frameworks
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
  # Pods for OneSignalNotificationServiceExtension
end

target 'DevOneSignalNotificationServiceExtension' do
  # Comment the next line if you don't want to use dynamic frameworks
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
  # Pods for DevOneSignalNotificationServiceExtension
end

@rgomezp ์ด๊ฒƒ์„ ์กฐ์‚ฌ ํ•˜๋Š” ์‚ฌ๋žŒ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ๋Š” react-native 0.59(cocoapods ์—†์Œ)๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ ์—ฌ๊ธฐ์˜ ๋ฌธ์ œ๋กœ ์ธํ•ด XCode 12์—์„œ ๋นŒ๋“œ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

@rgomezp ์ด๊ฒƒ์„ ์กฐ์‚ฌ ํ•˜๋Š” ์‚ฌ๋žŒ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ๋Š” react-native 0.59(cocoapods ์—†์Œ)๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ ์—ฌ๊ธฐ์˜ ๋ฌธ์ œ๋กœ ์ธํ•ด XCode 12์—์„œ ๋นŒ๋“œ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰ ์—…๋ฐ์ดํŠธ ํ›„ react-native 0.59 ๋ฐ Xcode 12์—๋Š” ์˜ค๋ฅ˜๊ฐ€ ์„ค๋ช…๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์—…๋ฐ์ดํŠธ ์ „์— ๋ชจ๋‘ ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. react-native-onesignal 3.9.2๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋‹ค์‹œ ์„ค์น˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

clang: error: no such file or directory: '/Users/leonardo/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphonesimulator/libRCTOneSignal.a' Command Ld failed with a nonzero exit code

image

์—…๋ฐ์ดํŠธ 1:
ํ”„๋กœ๋•์…˜์šฉ ์•ฑ์„ ๋นŒ๋“œํ•˜๋ฉด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค... ๋ฌธ์ œ๋Š” ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ ์‹คํ–‰ํ•˜๋ ค๊ณ  ํ•  ๋•Œ์ž…๋‹ˆ๋‹ค(๋ชจ๋‘ ๋‹ค๋ฅธ iOS์—์„œ)

์—…๋ฐ์ดํŠธ 2:
๋ฌผ๋ฆฌ์  ์žฅ์น˜์—์„œ๋„ ๋””๋ฒ„๊น…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—…๋ฐ์ดํŠธ 3:
๋””๋ฒ„๊น…ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ onesignal์€ ์‚ฌ์šฉ์ž ๋™์˜๋ฅผ ํ‘œ์‹œํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ตœ์‹  ๋ฒ„์ „ 3.9.2๋„ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.

๋‚˜๋ฅผ ์œ„ํ•œ ํ•ด๊ฒฐ์ฑ…์€ xcode๋ฅผ 11.7๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๊ณ  ios ํด๋”์˜ ๋ฐฑ์—…์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ œ๋Š” xcode 12+์™€ ๊ด€๋ จ๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

@Tebrynn์ด ๋งํ–ˆ๋“ฏ์ด XCode๋ฅผ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๋ ค๊ณ  ์‹œ๋„ํ–ˆ์ง€๋งŒ ๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ๊ณ„์† ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
์ €์—๊ฒŒ ์œ ์ผํ•œ ํ•ด๊ฒฐ์ฑ…์€ ์ˆ˜๋™ ์„ค์น˜๋ฅผ Cocoapods ์„ค์น˜๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.
๋ฐฉ๊ธˆ ์„ค๋ช…์„œ(https://documentation.onesignal.com/docs/react-native-sdk-setup)์˜ ์ง€์นจ์„ ๋”ฐ๋ž์Šต๋‹ˆ๋‹ค.

์ด์— ๋Œ€ํ•œ ํ•ด๊ฒฐ์ฑ…์ด ์žˆ์Šต๋‹ˆ๊นŒ?

๋ฐฉ๊ธˆ Xcode12๋กœ ์—…๋ฐ์ดํŠธํ–ˆ๋Š”๋ฐ ๋นŒ๋“œ ์‹œ์—๋„ ์ด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

์ตœ๊ทผ์— Xcode 12๋กœ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค. libRCTOneSignal.a๋ฅผ ์ฐพ์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋‚˜๋Š” ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ์‹œ๋„ํ•œ ๋‹จ๊ณ„์™€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ๋”ฐ๋ž๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋‚˜๋Š” ์–ด๋ฆฌ๋‘ฅ์ ˆํ•˜๋‹ค.
OneSignal์— ๋Œ€ํ•ด arm64๋ฅผ ์ œ์™ธํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ ๊ธฐ์‚ฌ๋ฅผ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋Š” ์ง€๊ธˆ๊นŒ์ง€ ์šด์ด ์—†์ด ์ด๊ฒƒ์„ ์‹œ๋„ํ–ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์—๋งŒ ์˜ํ–ฅ์„ ๋ฏธ์น˜๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ฌธ์ œ์— ๋” ๋งŽ์€ ์‹œ๊ฐ„์„ ํ• ์• ํ•˜์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋™์ผํ•œ ๋ฌธ์ œ, Xcode 12.4 ๋ฐ RN 0.59.10.

๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ์—ฌ๊ธฐ์— ์žˆ์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•,
์–ด๋–ป๊ฒŒ๋“  ์ˆ˜๋™ ์„ค์น˜๊ฐ€ ์ค‘๋‹จ๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์กฐ์‚ฌ๋ฅผ ์œ„ํ•ด ๋” ํŒŒํ—ค์ณ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๊ธฐ๋‹ค๋ ค ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ๋™์•ˆ ๊ฐ€๋Šฅํ•˜๋ฉด Cocoapods ์„ค์น˜ ๋ฐฉ์‹์œผ๋กœ ์ „ํ™˜ํ•ด ๋ณด์„ธ์š”.

๋‚˜๋Š” ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉด ํ•ด์žˆ๋‹ค. ์–ด๋–ค ํ•ด๊ฒฐ์ฑ…์ด ์žˆ์Šต๋‹ˆ๊นŒ?

์•ˆ๋…•ํ•˜์„ธ์š”, React-Native-OneSignal ๋ฒ„์ „ 4.0.0๋ถ€ํ„ฐ RCTOneSignal.xcodeproj์— ํฌํ•จ๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ์ฆ‰, NotificationServiceExtension์— OneSignal์„ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด Cocoapods๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
Podfile์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 3.0', '< 4.0'
end

๊ทธ๋Ÿฐ ๋‹ค์Œ Swift๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ NotificationService ํŒŒ์ผ์„ ๋‹ค์Œ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜์‹ญ์‹œ์˜ค.

import UserNotifications

import OneSignal

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: <strong i="10">@escaping</strong> (UNNotificationContent) -> Void) {
        self.receivedRequest = request;
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

        if let bestAttemptContent = bestAttemptContent {
            OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }

    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }

}

๋˜๋Š” Objective-C๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ

#import <OneSignal/OneSignal.h>

#import "NotificationService.h"

<strong i="14">@interface</strong> NotificationService ()

<strong i="15">@property</strong> (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
<strong i="16">@property</strong> (nonatomic, strong) UNNotificationRequest *receivedRequest;
<strong i="17">@property</strong> (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

<strong i="18">@end</strong>

<strong i="19">@implementation</strong> NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.receivedRequest = request;
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    [OneSignal didReceiveNotificationExtensionRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];

    // DEBUGGING: Uncomment the 2 lines below and comment out the one above to ensure this extension is excuting
    //            Note, this extension only runs when mutable-content is set
    //            Setting an attachment or action buttons automatically adds this
    // NSLog(@"Running NotificationServiceExtension");
    // self.bestAttemptContent.body = [@"[Modified] " stringByAppendingString:self.bestAttemptContent.body];

    self.contentHandler(self.bestAttemptContent);
}

- (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.

    [OneSignal serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];

    self.contentHandler(self.bestAttemptContent);
}

<strong i="20">@end</strong>

์ „์ฒด ์„ค์ • ๊ฐ€์ด๋“œ๋Š” ์—ฌ๊ธฐ ์—์„œ ์ฐพ์„ ์ˆ˜

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰