Skip to content

Commit 575f492

Browse files
committed
feat: add AppStore requestReview method, replace deprecated SKStoreReviewController
1 parent c689818 commit 575f492

File tree

7 files changed

+35
-26
lines changed

7 files changed

+35
-26
lines changed

Example/ios/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ SPEC CHECKSUMS:
18011801
ReactAppDependencyProvider: 3d947e9d62f351c06c71497e1be897e6006dc303
18021802
ReactCodegen: 1baa534318b19e95fb0f02db0a1ae1e3c271944d
18031803
ReactCommon: 6014af4276bb2debc350e2620ef1bd856b4d981c
1804-
RNStoreReview: ac782bdf6046ceebd82f3f39a2c6c41fbe99be43
1804+
RNStoreReview: 9e682bc8a29b4c67007fc15855e330d1838d3aac
18051805
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
18061806
Yoga: 78d74e245ed67bb94275a1316cdc170b9b7fe884
18071807

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-store-review
22

3-
This module exposes the native APIs to ask the user to rate the app in the iOS App Store or Google Play store directly from within the app (requires iOS >= 12.4 or Android 5.0 with Google Play store installed).
3+
This module exposes the native APIs to ask the user to rate the app in the iOS App Store or Google Play store directly from within the app (requires iOS >= 14.0 or Android 5.0 with Google Play store installed).
44

55
<img width="274" alt="Rating Dialog" src="https://cloud.githubusercontent.com/assets/378279/24377493/d22eb0b8-133f-11e7-9968-44d186a3801f.png">
66

RNStoreReview.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Pod::Spec.new do |s|
88
s.homepage = "https://github.com/oblador/react-native-store-review"
99
s.license = "MIT"
1010
s.author = { "Joel Arvidsson" => "joel@oblador.se" }
11-
s.platform = :ios, "12.4"
11+
s.platform = :ios, "14.0"
1212
s.source = { :git => "https://github.com/oblador/react-native-store-review.git", :tag => "v#{s.version}" }
13-
s.source_files = "ios/*.{h,m,mm}"
13+
s.source_files = "ios/*.{h,m,mm,swift}"
1414
s.preserve_paths = "**/*.js"
1515
s.ios.framework = 'StoreKit'
1616
s.requires_arc = true

ios/RNStoreReview.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#import <Foundation/Foundation.h>
2-
#import <React/RCTBridgeModule.h>
32

3+
#ifdef RCT_NEW_ARCH_ENABLED
4+
5+
#import <RNStoreReviewSpec/RNStoreReviewSpec.h>
6+
@interface RNStoreReview: NSObject <NativeRNStoreReviewSpec>
7+
8+
#else
9+
10+
#import <React/RCTBridgeModule.h>
411
@interface RNStoreReview : NSObject <RCTBridgeModule>
512

13+
#endif
14+
615
@end

ios/RNStoreReview.mm

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#import "RNStoreReview.h"
2-
#import <StoreKit/SKStoreReviewController.h>
32

4-
#ifdef RCT_NEW_ARCH_ENABLED
5-
#import <RNStoreReviewSpec/RNStoreReviewSpec.h>
6-
#endif
3+
#import "RNStoreReview-Swift.h"
74

85
@implementation RNStoreReview
96

@@ -16,21 +13,7 @@ - (dispatch_queue_t)methodQueue
1613

1714
RCT_EXPORT_METHOD(requestReview)
1815
{
19-
if (@available(iOS 14.0, *)) {
20-
UIWindowScene *activeScene;
21-
NSSet *scenes = [[UIApplication sharedApplication] connectedScenes];
22-
for (UIScene *scene in scenes) {
23-
if ([scene activationState] == UISceneActivationStateForegroundActive) {
24-
activeScene = scene;
25-
break;
26-
}
27-
}
28-
if (activeScene != nil) {
29-
[SKStoreReviewController requestReviewInScene:activeScene];
30-
}
31-
} else {
32-
[SKStoreReviewController requestReview];
33-
}
16+
[StoreReview requestReview];
3417
}
3518

3619
#ifdef RCT_NEW_ARCH_ENABLED

ios/StoreReview.swift

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Foundation
2+
import StoreKit
3+
4+
@objc
5+
public class StoreReview: NSObject {
6+
7+
@MainActor
8+
@objc
9+
public static func requestReview() {
10+
if let activeScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
11+
if #available(iOS 16.0, *) {
12+
AppStore.requestReview(in: activeScene)
13+
} else {
14+
SKStoreReviewController.requestReview(in: activeScene)
15+
}
16+
}
17+
}
18+
}

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@
5454
"javaPackageName": "com.oblador.storereview"
5555
}
5656
},
57-
"license": "MIT",
58-
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
57+
"license": "MIT"
5958
}

0 commit comments

Comments
 (0)