Skip to content

Commit c4ee592

Browse files
committed
Patch react-native-store-review
Changes sourced from: oblador/react-native-store-review@575f492
1 parent 0a2fa5d commit c4ee592

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
diff --git a/node_modules/react-native-store-review/RNStoreReview.podspec b/node_modules/react-native-store-review/RNStoreReview.podspec
2+
index c1a73b7..c36ba9b 100644
3+
--- a/node_modules/react-native-store-review/RNStoreReview.podspec
4+
+++ b/node_modules/react-native-store-review/RNStoreReview.podspec
5+
@@ -10,9 +10,9 @@ Pod::Spec.new do |s|
6+
s.homepage = "https://github.com/oblador/react-native-store-review"
7+
s.license = "MIT"
8+
s.author = { "Joel Arvidsson" => "[email protected]" }
9+
- s.platform = :ios, "12.4"
10+
+ s.platform = :ios, "14.0"
11+
s.source = { :git => "https://github.com/oblador/react-native-store-review.git", :tag => "v#{s.version}" }
12+
- s.source_files = "ios/*.{h,m,mm}"
13+
+ s.source_files = "ios/*.{h,m,mm,swift}"
14+
s.preserve_paths = "**/*.js"
15+
s.ios.framework = 'StoreKit'
16+
s.requires_arc = true
17+
diff --git a/node_modules/react-native-store-review/ios/RNStoreReview.h b/node_modules/react-native-store-review/ios/RNStoreReview.h
18+
index 22e267f..c38ed17 100644
19+
--- a/node_modules/react-native-store-review/ios/RNStoreReview.h
20+
+++ b/node_modules/react-native-store-review/ios/RNStoreReview.h
21+
@@ -1,6 +1,15 @@
22+
#import <Foundation/Foundation.h>
23+
-#import <React/RCTBridgeModule.h>
24+
25+
+#ifdef RCT_NEW_ARCH_ENABLED
26+
+
27+
+#import <RNStoreReviewSpec/RNStoreReviewSpec.h>
28+
+@interface RNStoreReview: NSObject <NativeRNStoreReviewSpec>
29+
+
30+
+#else
31+
+
32+
+#import <React/RCTBridgeModule.h>
33+
@interface RNStoreReview : NSObject <RCTBridgeModule>
34+
35+
+#endif
36+
+
37+
@end
38+
diff --git a/node_modules/react-native-store-review/ios/RNStoreReview.mm b/node_modules/react-native-store-review/ios/RNStoreReview.mm
39+
index ac6d298..0c609db 100644
40+
--- a/node_modules/react-native-store-review/ios/RNStoreReview.mm
41+
+++ b/node_modules/react-native-store-review/ios/RNStoreReview.mm
42+
@@ -1,9 +1,6 @@
43+
#import "RNStoreReview.h"
44+
-#import <StoreKit/SKStoreReviewController.h>
45+
46+
-#ifdef RCT_NEW_ARCH_ENABLED
47+
-#import <RNStoreReviewSpec/RNStoreReviewSpec.h>
48+
-#endif
49+
+#import "RNStoreReview-Swift.h"
50+
51+
@implementation RNStoreReview
52+
53+
@@ -16,21 +13,7 @@ RCT_EXPORT_MODULE()
54+
55+
RCT_EXPORT_METHOD(requestReview)
56+
{
57+
- if (@available(iOS 14.0, *)) {
58+
- UIWindowScene *activeScene;
59+
- NSSet *scenes = [[UIApplication sharedApplication] connectedScenes];
60+
- for (UIScene *scene in scenes) {
61+
- if ([scene activationState] == UISceneActivationStateForegroundActive) {
62+
- activeScene = scene;
63+
- break;
64+
- }
65+
- }
66+
- if (activeScene != nil) {
67+
- [SKStoreReviewController requestReviewInScene:activeScene];
68+
- }
69+
- } else {
70+
- [SKStoreReviewController requestReview];
71+
- }
72+
+ [StoreReview requestReview];
73+
}
74+
75+
#ifdef RCT_NEW_ARCH_ENABLED
76+
diff --git a/node_modules/react-native-store-review/ios/StoreReview.swift b/node_modules/react-native-store-review/ios/StoreReview.swift
77+
new file mode 100644
78+
index 0000000..b528da2
79+
--- /dev/null
80+
+++ b/node_modules/react-native-store-review/ios/StoreReview.swift
81+
@@ -0,0 +1,18 @@
82+
+import Foundation
83+
+import StoreKit
84+
+
85+
+@objc
86+
+public class StoreReview: NSObject {
87+
+
88+
+ @MainActor
89+
+ @objc
90+
+ public static func requestReview() {
91+
+ if let activeScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
92+
+ if #available(iOS 16.0, *) {
93+
+ AppStore.requestReview(in: activeScene)
94+
+ } else {
95+
+ SKStoreReviewController.requestReview(in: activeScene)
96+
+ }
97+
+ }
98+
+ }
99+
+}

0 commit comments

Comments
 (0)