-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solve request review deprecated iOS (#53)
* bump-version-minor * upgrade request review to support iOS 14+ * impl. method isAvailable * rename error name getting from activity android * update README.md
- Loading branch information
1 parent
f437af4
commit b608e56
Showing
10 changed files
with
28,017 additions
and
28,003 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,3 @@ | |
#else | ||
#import <React/RCTBridgeModule.h> | ||
#endif | ||
|
||
@interface RNInAppReviewIOS : NSObject <RCTBridgeModule> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,22 @@ | ||
#import "RNInAppReviewIOS.h" | ||
#import <Foundation/Foundation.h> | ||
#import <StoreKit/SKStoreReviewController.h> | ||
#import <UIKit/UIKit.h> | ||
#import "RCTBridgeModule.h" | ||
|
||
@implementation RNInAppReviewIOS | ||
|
||
@interface RCT_EXTERN_MODULE(RNInAppReviewIOS, NSObject) | ||
|
||
- (dispatch_queue_t)methodQueue | ||
{ | ||
return dispatch_get_main_queue(); | ||
} | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
- (NSDictionary *)constantsToExport | ||
{ | ||
return @{ | ||
@"isAvailable": [SKStoreReviewController class] ? @(YES) : @(NO) | ||
}; | ||
} | ||
|
||
RCT_EXPORT_METHOD(requestReview: | ||
resolver:(RCTPromiseResolveBlock)resolve | ||
rejecter:(RCTPromiseRejectBlock)reject) { | ||
if (@available(iOS 10.3, *)) { | ||
[SKStoreReviewController requestReview]; | ||
resolve(@"true"); | ||
}else{ | ||
reject(@"21",@"ERROR_DEVICE_VERSION",nil); | ||
} | ||
} | ||
RCT_EXTERN_METHOD(requestReview: | ||
(RCTPromiseResolveBlock)resolve | ||
rejecter:(RCTPromiseRejectBlock)reject) | ||
|
||
+ (BOOL)requiresMainQueueSetup | ||
{ | ||
return YES; | ||
} | ||
|
||
@end | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Foundation | ||
import UIKit | ||
import StoreKit | ||
|
||
@objc(RNInAppReviewIOS) | ||
class RNInAppReviewIOS: NSObject { | ||
|
||
@objc | ||
func requestReview (_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void { | ||
if #available(iOS 14.0, *) { | ||
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene { | ||
SKStoreReviewController.requestReview(in: scene) | ||
resolve("true"); | ||
} else { | ||
reject("25","SCENE_DOESN'T_EXIST",nil); | ||
} | ||
} else if #available(iOS 10.3, *) { | ||
SKStoreReviewController.requestReview() | ||
resolve("true"); | ||
} else { | ||
reject("21","ERROR_DEVICE_VERSION",nil); | ||
} | ||
} | ||
|
||
@objc | ||
func constantsToExport() -> [String: Any]! { | ||
return ["isAvailable": (NSClassFromString("SKStoreReviewController") != nil) ? (true) : (false)] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.