Skip to content

Commit fcf4ec2

Browse files
authored
feat(in-app-review): use AppStore.requestReview on supported newer iOS versions (#20)
* chore: nx migrate @nativescript/plugin-tools * feat(in-app-review): use AppStore.requestReview on supported newer iOS versions * feat: support visionOS * chore: cleanup
1 parent e7e885a commit fcf4ec2

File tree

6 files changed

+793
-627
lines changed

6 files changed

+793
-627
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "0.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"postinstall": "husky install && npx ts-patch install",
7-
"setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && yarn config set ignore-engines true && ns package-manager set npm && yarn",
6+
"postinstall": "husky && npx ts-patch install",
7+
"setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && yarn",
88
"start": "nps",
99
"add": "nx g @nativescript/plugin-tools:add-package",
1010
"add-angular": "nx g @nativescript/plugin-tools:add-angular",
@@ -73,6 +73,6 @@
7373
]
7474
},
7575
"dependencies": {
76-
"@ngrx/operators": "^18.0.0"
76+
"@ngrx/operators": "^19.0.0"
7777
}
7878
}

packages/nativescript-in-app-review/index.android.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application, Utils } from '@nativescript/core';
1+
import { Utils } from '@nativescript/core';
22
import { InAppReviewCommon } from './common';
33

44
export class InAppReview extends InAppReviewCommon {
@@ -31,11 +31,11 @@ export class InAppReview extends InAppReviewCommon {
3131
resolve();
3232
}
3333
},
34-
})
34+
}),
3535
);
3636
},
37-
})
38-
)
37+
}),
38+
),
3939
);
4040
}
4141
}

packages/nativescript-in-app-review/index.ios.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
import { Application, Device } from '@nativescript/core';
1+
import { Application, Utils } from '@nativescript/core';
22
import { InAppReviewCommon } from './common';
33

4+
let nscAppStore: NSCAppStore;
5+
46
export class InAppReview extends InAppReviewCommon {
57
static requestReviewPopup() {
6-
if (+Device.sdkVersion < 14.0) {
8+
if (Utils.SDK_VERSION >= 17 || __VISIONOS__) {
9+
if (!nscAppStore) {
10+
nscAppStore = NSCAppStore.new();
11+
}
12+
nscAppStore.requestReview();
13+
} else if (Utils.SDK_VERSION < 14) {
714
SKStoreReviewController.requestReview();
815
} else {
916
SKStoreReviewController.requestReviewInScene((Application.ios.window as UIWindow).windowScene);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import StoreKit
2+
3+
@objc public class NSCAppStore: NSObject {
4+
@MainActor
5+
@objc public func requestReview() {
6+
if #available(iOS 16.0, *) {
7+
let windowScene = UIApplication.shared.windows.first?.windowScene
8+
if (windowScene == nil) {
9+
guard let scene = UIApplication.shared.connectedScenes.first,
10+
let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,
11+
let window = windowSceneDelegate.window else {
12+
return
13+
}
14+
AppStore.requestReview(in: window!.windowScene!)
15+
return
16+
}
17+
18+
AppStore.requestReview(in: windowScene!)
19+
}
20+
}
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare class NSCAppStore extends NSObject {
2+
3+
static alloc(): NSCAppStore; // inherited from NSObject
4+
5+
static new(): NSCAppStore; // inherited from NSObject
6+
7+
requestReview(): void;
8+
}

0 commit comments

Comments
 (0)