react-native-rate-app 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RateApp.podspec +1 -1
- package/ios/RateApp.mm +21 -50
- package/ios/RateApp.swift +55 -0
- package/lib/module/plugin/withReactNativeRateApp.js +2 -5
- package/lib/module/plugin/withReactNativeRateApp.js.map +1 -1
- package/lib/typescript/src/plugin/withReactNativeRateApp.d.ts +11 -0
- package/lib/typescript/src/plugin/withReactNativeRateApp.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/plugin/{withReactNativeRateApp.js → withReactNativeRateApp.ts} +9 -5
package/RateApp.podspec
CHANGED
|
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.platforms = { :ios => min_ios_version_supported }
|
|
14
14
|
s.source = { :git => "https://github.com/huextrat/react-native-rate-app.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp,swift}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
|
|
19
19
|
install_modules_dependencies(s)
|
package/ios/RateApp.mm
CHANGED
|
@@ -1,74 +1,45 @@
|
|
|
1
1
|
#import "RateApp.h"
|
|
2
|
+
#import "RateApp-Swift.h"
|
|
2
3
|
#import <React/RCTBridgeModule.h>
|
|
3
|
-
#import <StoreKit/StoreKit.h>
|
|
4
|
-
#import <UIKit/UIKit.h>
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@implementation RateApp
|
|
5
|
+
@implementation RateApp {
|
|
6
|
+
RateAppImpl *_impl;
|
|
7
|
+
}
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- (instancetype)init {
|
|
10
|
+
self = [super init];
|
|
11
|
+
if (self) {
|
|
12
|
+
_impl = [RateAppImpl new];
|
|
13
|
+
}
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
|
-
- (
|
|
17
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
18
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
14
19
|
{
|
|
15
|
-
|
|
16
|
-
NSSet<UIScene *> *scenes = [UIApplication sharedApplication].connectedScenes;
|
|
17
|
-
for (UIScene *scene in scenes) {
|
|
18
|
-
if ([scene isKindOfClass:[UIWindowScene class]] &&
|
|
19
|
-
scene.activationState == UISceneActivationStateForegroundActive) {
|
|
20
|
-
return (UIWindowScene *)scene;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return nil;
|
|
20
|
+
return std::make_shared<facebook::react::NativeRateAppSpecJSI>(params);
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
+ (NSString *)moduleName
|
|
24
|
+
{
|
|
25
|
+
return @"RateApp";
|
|
26
|
+
}
|
|
28
27
|
|
|
29
28
|
- (void)requestReview:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
30
29
|
{
|
|
31
|
-
|
|
32
|
-
if (scene == nil) {
|
|
33
|
-
reject(kNoActiveSceneError, @"No active scene found", nil);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
38
|
-
if (@available(iOS 14.0, *)) {
|
|
39
|
-
[SKStoreReviewController requestReviewInScene:scene];
|
|
40
|
-
} else {
|
|
41
|
-
[SKStoreReviewController requestReview];
|
|
42
|
-
}
|
|
43
|
-
resolve(@YES);
|
|
44
|
-
});
|
|
30
|
+
[_impl requestReview:resolve reject:reject];
|
|
45
31
|
}
|
|
46
32
|
|
|
47
33
|
- (void)requestReviewAppGallery:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
48
34
|
{
|
|
49
|
-
reject
|
|
50
|
-
@"App Gallery reviews are not supported on iOS",
|
|
51
|
-
nil);
|
|
35
|
+
[_impl requestReviewAppGallery:resolve reject:reject];
|
|
52
36
|
}
|
|
53
37
|
|
|
54
38
|
- (void)requestReviewGalaxyStore:(NSString *)packageName
|
|
55
39
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
56
40
|
reject:(RCTPromiseRejectBlock)reject
|
|
57
41
|
{
|
|
58
|
-
reject
|
|
59
|
-
@"Galaxy Store reviews are not supported on iOS",
|
|
60
|
-
nil);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
64
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
65
|
-
{
|
|
66
|
-
return std::make_shared<facebook::react::NativeRateAppSpecJSI>(params);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
+ (NSString *)moduleName
|
|
70
|
-
{
|
|
71
|
-
return @"RateApp";
|
|
42
|
+
[_impl requestReviewGalaxyStore:packageName resolve:resolve reject:reject];
|
|
72
43
|
}
|
|
73
44
|
|
|
74
45
|
@end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import React
|
|
3
|
+
import StoreKit
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
6
|
+
@objc(RateAppImpl)
|
|
7
|
+
public class RateAppImpl: NSObject {
|
|
8
|
+
|
|
9
|
+
private let noActiveSceneError = "no_active_scene"
|
|
10
|
+
private let unsupportedPlatformError = "unsupported_platform"
|
|
11
|
+
|
|
12
|
+
@objc
|
|
13
|
+
public func requestReview(
|
|
14
|
+
_ resolve: @escaping RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
|
|
15
|
+
) {
|
|
16
|
+
if let scene = findActiveScene() {
|
|
17
|
+
if #available(iOS 16.0, *) {
|
|
18
|
+
Task { @MainActor in
|
|
19
|
+
AppStore.requestReview(in: scene)
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
SKStoreReviewController.requestReview(in: scene)
|
|
23
|
+
}
|
|
24
|
+
resolve(true)
|
|
25
|
+
} else {
|
|
26
|
+
reject(noActiveSceneError, "No active scene found", nil)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@objc
|
|
31
|
+
public func requestReviewAppGallery(
|
|
32
|
+
_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
|
|
33
|
+
) {
|
|
34
|
+
reject(unsupportedPlatformError, "App Gallery reviews are not supported on iOS", nil)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@objc
|
|
38
|
+
public func requestReviewGalaxyStore(
|
|
39
|
+
_ packageName: String, resolve: RCTPromiseResolveBlock,
|
|
40
|
+
reject: RCTPromiseRejectBlock
|
|
41
|
+
) {
|
|
42
|
+
reject(unsupportedPlatformError, "Galaxy Store reviews are not supported on iOS", nil)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private func findActiveScene() -> UIWindowScene? {
|
|
46
|
+
for scene in UIApplication.shared.connectedScenes {
|
|
47
|
+
if let windowScene = scene as? UIWindowScene,
|
|
48
|
+
windowScene.activationState == .foregroundActive
|
|
49
|
+
{
|
|
50
|
+
return windowScene
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return nil
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
withInfoPlist,
|
|
5
|
-
withXcodeProject
|
|
6
|
-
} = require('@expo/config-plugins');
|
|
3
|
+
import { withInfoPlist, withXcodeProject } from '@expo/config-plugins';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Modifies the `Info.plist` file to add `LSApplicationQueriesSchemes`,
|
|
@@ -52,5 +49,5 @@ const withReactNativeRateApp = config => {
|
|
|
52
49
|
const configWithStoreKit = withStoreKitFramework(configWithInfoPlist);
|
|
53
50
|
return configWithStoreKit;
|
|
54
51
|
};
|
|
55
|
-
|
|
52
|
+
export default withReactNativeRateApp;
|
|
56
53
|
//# sourceMappingURL=withReactNativeRateApp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withInfoPlist","withXcodeProject","
|
|
1
|
+
{"version":3,"names":["withInfoPlist","withXcodeProject","withCustomInfoPlist","config","modResults","LSApplicationQueriesSchemes","includes","push","withStoreKitFramework","addFramework","required","withReactNativeRateApp","configWithInfoPlist","configWithStoreKit"],"sourceRoot":"../../../src","sources":["plugin/withReactNativeRateApp.ts"],"mappings":";;AAAA,SAEEA,aAAa,EACbC,gBAAgB,QACX,sBAAsB;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAiC,GAAIC,MAAM,IAAK;EACpD,OAAOH,aAAa,CAACG,MAAM,EAAGA,MAAM,IAAK;IACvC,IAAI,CAACA,MAAM,CAACC,UAAU,CAACC,2BAA2B,EAAE;MAClDF,MAAM,CAACC,UAAU,CAACC,2BAA2B,GAAG,EAAE;IACpD;IACA,IAAI,CAACF,MAAM,CAACC,UAAU,CAACC,2BAA2B,CAACC,QAAQ,CAAC,WAAW,CAAC,EAAE;MACxEH,MAAM,CAACC,UAAU,CAACC,2BAA2B,CAACE,IAAI,CAAC,WAAW,CAAC;IACjE;IACA,OAAOJ,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,qBAAmC,GAAIL,MAAM,IAAK;EACtD,OAAOF,gBAAgB,CAACE,MAAM,EAAGA,MAAM,IAAK;IAC1CA,MAAM,CAACC,UAAU,CAACK,YAAY,CAAC,oBAAoB,EAAE;MAAEC,QAAQ,EAAE;IAAK,CAAC,CAAC;IACxE,OAAOP,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMQ,sBAAoC,GAAIR,MAAM,IAAK;EACvD,MAAMS,mBAAmB,GAAGV,mBAAmB,CAACC,MAAM,CAAC;EACvD,MAAMU,kBAAkB,GAAGL,qBAAqB,CAACI,mBAAmB,CAAC;EACrE,OAAOC,kBAAkB;AAC3B,CAAC;AAED,eAAeF,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Applies both `withCustomInfoPlist` and `withStoreKitFramework`
|
|
4
|
+
* to enable in-app rating functionality in a React Native app.
|
|
5
|
+
*
|
|
6
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
7
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
8
|
+
*/
|
|
9
|
+
declare const withReactNativeRateApp: ConfigPlugin;
|
|
10
|
+
export default withReactNativeRateApp;
|
|
11
|
+
//# sourceMappingURL=withReactNativeRateApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withReactNativeRateApp.d.ts","sourceRoot":"","sources":["../../../../src/plugin/withReactNativeRateApp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAmC9B;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,EAAE,YAI7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ConfigPlugin,
|
|
3
|
+
withInfoPlist,
|
|
4
|
+
withXcodeProject,
|
|
5
|
+
} from '@expo/config-plugins';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Modifies the `Info.plist` file to add `LSApplicationQueriesSchemes`,
|
|
@@ -7,7 +11,7 @@ const { withInfoPlist, withXcodeProject } = require('@expo/config-plugins');
|
|
|
7
11
|
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
8
12
|
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
9
13
|
*/
|
|
10
|
-
const withCustomInfoPlist = (config) => {
|
|
14
|
+
const withCustomInfoPlist: ConfigPlugin = (config) => {
|
|
11
15
|
return withInfoPlist(config, (config) => {
|
|
12
16
|
if (!config.modResults.LSApplicationQueriesSchemes) {
|
|
13
17
|
config.modResults.LSApplicationQueriesSchemes = [];
|
|
@@ -26,7 +30,7 @@ const withCustomInfoPlist = (config) => {
|
|
|
26
30
|
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
27
31
|
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
28
32
|
*/
|
|
29
|
-
const withStoreKitFramework = (config) => {
|
|
33
|
+
const withStoreKitFramework: ConfigPlugin = (config) => {
|
|
30
34
|
return withXcodeProject(config, (config) => {
|
|
31
35
|
config.modResults.addFramework('StoreKit.framework', { required: true });
|
|
32
36
|
return config;
|
|
@@ -40,10 +44,10 @@ const withStoreKitFramework = (config) => {
|
|
|
40
44
|
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
41
45
|
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
42
46
|
*/
|
|
43
|
-
const withReactNativeRateApp = (config) => {
|
|
47
|
+
const withReactNativeRateApp: ConfigPlugin = (config) => {
|
|
44
48
|
const configWithInfoPlist = withCustomInfoPlist(config);
|
|
45
49
|
const configWithStoreKit = withStoreKitFramework(configWithInfoPlist);
|
|
46
50
|
return configWithStoreKit;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
export default withReactNativeRateApp;
|