File tree 10 files changed +28017
-28003
lines changed
android/src/main/java/com/ibits/react_native_in_app_review
RNInAppReviewIOS.xcodeproj
10 files changed +28017
-28003
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,9 @@ InAppReview.RequestInAppReview()
203
203
| ERROR_DEVICE_VERSION | 21 | This Device not supported to lanuch InAppReview | ✅ | ✅ |
204
204
| GOOGLE_SERVICES_NOT_AVAILABLE | 22 | This Device doesn't support google play services | ❌ | ✅ |
205
205
| [ DYNAMIC ERROR NAME] | 23 | Unexpected error occur may return different error from different user and device check code number to get discovered errors messages that could be happen. | ❌ | ✅ |
206
+ | ACTIVITY_DOESN'T_EXIST | 24 | Unexpected error occur while getting activity | ❌ | ✅ |
207
+ | SCENE_DOESN'T_EXIST | 25 | Unexpected error occur while getting scene | ✅ | ❌ |
208
+
206
209
207
210
# + Android Notes:
208
211
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public void show(final Promise promise) {
51
51
Activity currentActivity = getCurrentActivity ();
52
52
53
53
if (currentActivity == null ) {
54
- rejectPromise ("24" , new Error ("Activity doesn't exist " ));
54
+ rejectPromise ("24" , new Error ("ACTIVITY_DOESN'T_EXIST " ));
55
55
return ;
56
56
}
57
57
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export default class InAppReview {
30
30
if ( Platform . OS === 'android' ) {
31
31
return InAppReviewModule . show ( ) ;
32
32
} else {
33
- return RNInAppReviewIOS . requestReview ( { } ) ;
33
+ return RNInAppReviewIOS . requestReview ( ) ;
34
34
}
35
35
}
36
36
}
Original file line number Diff line number Diff line change 3
3
#else
4
4
#import < React/RCTBridgeModule.h>
5
5
#endif
6
-
7
- @interface RNInAppReviewIOS : NSObject <RCTBridgeModule>
8
-
9
- @end
Original file line number Diff line number Diff line change 1
- #import " RNInAppReviewIOS.h "
1
+ #import < Foundation/Foundation.h >
2
2
#import < StoreKit/SKStoreReviewController.h>
3
+ #import < UIKit/UIKit.h>
4
+ #import " RCTBridgeModule.h"
3
5
4
- @implementation RNInAppReviewIOS
5
-
6
+ @interface RCT_EXTERN_MODULE (RNInAppReviewIOS, NSObject )
6
7
7
8
- (dispatch_queue_t )methodQueue
8
9
{
9
10
return dispatch_get_main_queue ();
10
11
}
11
12
12
- RCT_EXPORT_MODULE ()
13
-
14
- - (NSDictionary *)constantsToExport
15
- {
16
- return @{
17
- @" isAvailable" : [SKStoreReviewController class ] ? @(YES ) : @(NO )
18
- };
19
- }
20
-
21
- RCT_EXPORT_METHOD (requestReview:
22
- resolver:(RCTPromiseResolveBlock)resolve
23
- rejecter:(RCTPromiseRejectBlock)reject) {
24
- if (@available (iOS 10.3 , *)) {
25
- [SKStoreReviewController requestReview ];
26
- resolve (@" true" );
27
- }else {
28
- reject (@" 21" ,@" ERROR_DEVICE_VERSION" ,nil );
29
- }
30
- }
13
+ RCT_EXTERN_METHOD (requestReview:
14
+ (RCTPromiseResolveBlock)resolve
15
+ rejecter:(RCTPromiseRejectBlock)reject)
31
16
32
17
+ (BOOL )requiresMainQueueSetup
33
18
{
34
19
return YES ;
35
20
}
36
21
37
- @end
22
+ @end
Original file line number Diff line number Diff line change
1
+ import Foundation
2
+ import UIKit
3
+ import StoreKit
4
+
5
+ @objc ( RNInAppReviewIOS)
6
+ class RNInAppReviewIOS : NSObject {
7
+
8
+ @objc
9
+ func requestReview ( _ resolve: RCTPromiseResolveBlock , rejecter reject: RCTPromiseRejectBlock ) -> Void {
10
+ if #available( iOS 14 . 0 , * ) {
11
+ if let scene = UIApplication . shared. connectedScenes. first ( where: { $0. activationState == . foregroundActive } ) as? UIWindowScene {
12
+ SKStoreReviewController . requestReview ( in: scene)
13
+ resolve ( " true " ) ;
14
+ } else {
15
+ reject ( " 25 " , " SCENE_DOESN'T_EXIST " , nil ) ;
16
+ }
17
+ } else if #available( iOS 10 . 3 , * ) {
18
+ SKStoreReviewController . requestReview ( )
19
+ resolve ( " true " ) ;
20
+ } else {
21
+ reject ( " 21 " , " ERROR_DEVICE_VERSION " , nil ) ;
22
+ }
23
+ }
24
+
25
+ @objc
26
+ func constantsToExport( ) -> [ String : Any ] ! {
27
+ return [ " isAvailable " : ( NSClassFromString ( " SKStoreReviewController " ) != nil ) ? ( true ) : ( false ) ]
28
+ }
29
+ }
Original file line number Diff line number Diff line change 24
24
25
25
/* Begin PBXFileReference section */
26
26
134814201AA4EA6300B7C361 /* libRNInAppReviewIOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNInAppReviewIOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
- B3E7B5881CC2AC0600A0062D /* RNInAppReviewIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNInAppReviewIOS.h; sourceTree = "<group>"; };
27
+ B3E7B5881CC2AC0600A0062D /* RNInAppReviewIOS-Bridging-Header .h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNInAppReviewIOS-Bridging-Header .h; sourceTree = "<group>"; };
28
28
B3E7B5891CC2AC0600A0062D /* RNInAppReviewIOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNInAppReviewIOS.m; sourceTree = "<group>"; };
29
+ FA8B5363267515B100849ADB /* RNInAppReviewIOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNInAppReviewIOS.swift; sourceTree = "<group>"; };
29
30
/* End PBXFileReference section */
30
31
31
32
/* Begin PBXFrameworksBuildPhase section */
50
51
58B511D21A9E6C8500147676 = {
51
52
isa = PBXGroup;
52
53
children = (
53
- B3E7B5881CC2AC0600A0062D /* RNInAppReviewIOS.h */,
54
+ B3E7B5881CC2AC0600A0062D /* RNInAppReviewIOS-Bridging-Header .h */,
54
55
B3E7B5891CC2AC0600A0062D /* RNInAppReviewIOS.m */,
55
56
134814211AA4EA7D00B7C361 /* Products */,
56
57
);
You can’t perform that action at this time.
0 commit comments