Deep_Dev
article thumbnail

 

๐Ÿ“š ์ธ์•ฑ๋ฆฌ๋ทฐ(In-App Review)

 

์ด๋ฒˆ์— ํŒ€ํ”„๋กœ์ ํŠธ์˜ ๊ฐœ๋ฐœ์‹œ์ž‘์ด ์กฐ๊ธˆ์”ฉ ๊ณ„์† ๋ฏธ๋ค„์ง€๋ฉด์„œ, 

๊ฐœ๋ฐœํ•˜๊ณ ์‹ถ์€๋ฐ ํ•˜์ง€๋ชปํ•ด์„œ ์ตœ๊ทผ์— ์กฐ๊ธˆ์”ฉ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์žˆ๋Š” ๊ฐœ์ธํ”„๋กœ์ ํŠธ ์•ฑ์— ์ธ์•ฑ๋ฆฌ๋ทฐ๋ฅผ ๋„ฃ์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

์ธ์•ฑ๋ฆฌ๋ทฐ๋Š” ์•ฑ ๋‚ด์—์„œ ์•ฑ์˜ ์•ฑ์Šคํ† ์–ด ํ‰์ ๊ณผ ๋ฆฌ๋ทฐ๋ฅผ ๋‚จ๊ธธ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์‚ฌ์‹ค ์ œ๊ฐ€ ์ด๊ฑธ ์ ์šฉํ•˜๋ ค๋Š” ์•ฑ์ด ์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ์ง„ ์•Š์ง€๋งŒ ๊พธ์ค€ํžˆ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทผ๋ฐ ํ™•์žฅ์„ฑ์ด ๋„“์ง€ ์•Š์€ ๋‹จ์ผ ๊ธฐ๋Šฅ ์•ฑ์ด๋ผ.. ํ™•์žฅ์„ ํ•œ๋‹ค๋ฉด ์—„์ฒญ ํฌ๊ฒŒ ํ•ด์•ผํ•ด์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์˜๊ฒฌ์ด๋‚˜ ํ”ผ๋“œ๋ฐฑ์„ ์กฐ๊ธˆ ๋” ๋“ค์–ด๋ณด๊ณ  ์‹ถ์–ด์„œ ์ ์šฉํ•˜๋ คํ•ฉ๋‹ˆ๋‹ค.

 

์ œ๊ฐ€ SwiftUI๋ฅผ ์ฒ˜์Œ ๊ณต๋ถ€ํ•  ๋•Œ, ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์—ˆ๋˜ ์•ฑ์ธ๋ฐ ๋ฐฉ์น˜ํ•ด๋’€๋‹ค๊ฐ€ ๋‚˜์ค‘์— ๋ณด๋‹ˆ๊นŒ ๊ณ„์† ์“ฐ๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ์ด ์žˆ๋”๋ผ๊ตฌ์š”?

์ตœ๊ทผ์— ์ด๊ฒƒ์ €๊ฒƒ ์กฐ๊ธˆ์”ฉ ์—…๋ฐ์ดํŠธ ์ค‘์ž…๋‹ˆ๋‹ค !

 


StoreKit 

์ธ์•ฑ๋ฆฌ๋ทฐ๋Š” ์ด StoreKit ํ”„๋ ˆ์ž„์›Œํฌ์— ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

StoreKit์€ '์•ฑ ๋‚ด ๊ตฌ๋งค ๋ฐ App Store์™€์˜ ์ƒํ˜ธ ์ž‘์šฉ์„ ์ง€์›ํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ'์ž…๋‹ˆ๋‹ค.

 

์ž์„ธํ•œ๊ฑด ๊ณต์‹ ๋ฌธ์„œ ํ˜น์€ ๋ ˆํผ๋Ÿฐ์Šค ์ž๋ฃŒ๋“ค์ด ๋งŽ์œผ๋‹ˆ๊นŒ ์ฐพ์•„๋ณด๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

https://developer.apple.com/documentation/storekit

 

StoreKit | Apple Developer Documentation

Support In-App Purchases and interactions with the App Store.

developer.apple.com


์•ฑ ๋‚ด์—์„œ ์ธ์•ฑ๋ฆฌ๋ทฐ๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ œ๊ณตํ•˜๋Š” ๋ฐฉ์‹์€ 2๊ฐ€์ง€ ์ž…๋‹ˆ๋‹ค.

 

1. ์•ฑ์—์„œ ๋ฆฌ๋ทฐ๋ฅผ ํŒ์—…์œผ๋กœ ๋„์›Œ์„œ, ๋ณ„์ ์„ ๋งค๊ธฐ๊ณ  ๋งˆ๋ฌด๋ฆฌํ•˜๋Š” ๋ฐฉ์‹ ( ํ‰์†Œ ์ž์ฃผ ์ ‘ํ–ˆ๋˜ ๋ฐฉ์‹ )

2. ์•ฑ์Šคํ† ์–ด ํŽ˜์ด์ง€๋กœ ์ด๋™์‹œ์ผœ์„œ ์ƒ์„ธํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๊ฒŒ ๋˜๋Š” ๋ฐฉ์‹

 

์ฒซ๋ฒˆ์งธ ๋ฐฉ์‹ : ์•ฑ ๋‚ด์—์„œ ๋ณ„์  

import SwiftUI
import StoreKit

struct ContentView: View {
  var body: some View {
    VStack {
    	Button(action: {
            if let scene = UIApplication.shared.connectedScenes
            	.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
               	    SKStoreReviewController.requestReview(in: scene)
                }
            }, label: {
            	Text("App Reviews")
            })
    }
    .padding()
  }
}

StoreKit์„ ์ž„ํฌํŠธํ•˜๊ณ  ์ด๋ ‡๊ฒŒ Button์„ ๋ˆŒ๋ €์„๋•Œ, ๋ณ„์  ๋ฆฌ๋ทฐ๋ฅผ ๋‚จ๊ธธ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

SKStoreReviewController๋Š” ์‚ฌ์šฉ์ž์—๊ฒŒ ์•ฑ ์Šคํ† ์–ด ํ‰์  ๋ฐ ๋ฆฌ๋ทฐ๋ฅผ ์š”์ฒญํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ์ œ์–ดํ•˜๋Š” ๊ฐœ์ฒด์ž…๋‹ˆ๋‹ค.

 

 

์•„ ๊ทธ๋ฆฌ๊ณ .. ๋ฆฌ๋ทฐ ์š”์ฒญํ•˜๋Š” ์ฝ”๋“œ๋ฅผ Button๋‚ด์— ๋‹ฌ๋ฉด Text Color๊ฐ€ Blue์ƒ‰์ƒ์œผ๋กœ ์žกํžํ…๋ฐ,

ButtonStyle์—์„œ PlainButtonStyle์„ ์ ์šฉ์‹œ์ผœ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 


๋‘๋ฒˆ์งธ ๋ฐฉ์‹ : ์•ฑ์Šคํ† ์–ด ๋ฆฌ๋ทฐํŽ˜์ด์ง€ ์ด๋™ 

let appID = "ํ•ด๋‹นํ•˜๋Š” App ID"
let urlString = "https://apps.apple.com/app/id\(appID)?action=write-review"
if let url = URL(string: urlString) {
	UIApplication.shared.open(url)
}

์ด ์ฝ”๋“œ๋“ค์„ ์ฒซ๋ฒˆ์งธ ๋ฐฉ์‹์ฒ˜๋Ÿผ Button์•ˆ์— ๋ฉ”์†Œ๋“œ๋กœ ๋„ฃ๊ฑฐ๋‚˜ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค !

 

AppID๋Š” ๋ฐฐํฌ๋œ ์•ฑ์„ ์•ฑ์Šคํ† ์–ด๋กœ ๋“ค์–ด๊ฐ€๋ฉด ๋์— id + ์ˆซ์ž๋กœ ๋‚˜์˜ค๊ฒŒ ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค.

์ € ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” urlString์— id๋ฅผ ๋„ฃ์–ด์„œ ํ•œ๋ฒˆ์— ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

์ด ๋‘๋ฒˆ์งธ ๋ฐฉ์‹์€ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ ํ•˜๋ฉด ํ•ด๋‹น ์•ฑ์˜ ๋ฆฌ๋ทฐํŽ˜์ด์ง€๋ฅผ ์ฐพ์ง€๋ชปํ•ด์„œ ์˜์ƒ์€ ๋”ฐ๋กœ ํŒจ์Šคํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ! 

์‹ค๋ฌผ๊ธฐ๊ธฐ๋กœ ํ…Œ์ŠคํŠธํ•˜๋ฉด ์ž˜ ๋ฉ๋‹ˆ๋‹ค.

 

์‚ฌ์šฉ์ž๋“ค์ด ์›ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‚˜ ํ”ผ๋“œ๋ฐฑ์„ ๊ผญ ๋‚จ๊ฒจ์ฃผ์—ˆ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค :)