Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(in-app-review): use AppStore.requestReview on supported newer iOS versions #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/demo-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@valor/nativescript-in-app-review": "file:../../dist/packages/nativescript-in-app-review"
},
"devDependencies": {
"@nativescript/android": "~8.7.0",
"@nativescript/ios": "~8.7.0"
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0"
}
}
4 changes: 2 additions & 2 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@valor/nativescript-in-app-review": "file:../../packages/nativescript-in-app-review"
},
"devDependencies": {
"@nativescript/android": "~8.7.0",
"@nativescript/ios": "~8.7.0"
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0"
}
}
29 changes: 1 addition & 28 deletions migrations.json
Original file line number Diff line number Diff line change
@@ -1,28 +1 @@
{
"migrations": [
{
"cli": "nx",
"version": "5.1.0",
"description": "Migrate tools to 5.1.0",
"implementation": "./src/migrations/update-5-1-0/update-5-1-0",
"package": "@nativescript/plugin-tools",
"name": "update-to-5.1.0"
},
{
"cli": "nx",
"version": "5.2.0",
"description": "Migrate tools to 5.2.0",
"implementation": "./src/migrations/update-5-2-0/update-5-2-0",
"package": "@nativescript/plugin-tools",
"name": "update-to-5.2.0"
},
{
"cli": "nx",
"version": "5.3.0",
"description": "Migrate tools to 5.3.0",
"implementation": "./src/migrations/update-5-3-0/update-5-3-0",
"package": "@nativescript/plugin-tools",
"name": "update-to-5.3.0"
}
]
}
{ "migrations": [{ "cli": "nx", "version": "5.4.0", "description": "Migrate tools to 5.4.0", "implementation": "./src/migrations/update-5-4-0/update-5-4-0", "package": "@nativescript/plugin-tools", "name": "update-to-5.4.0" }] }
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "husky install && npx ts-patch install",
"setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && yarn config set ignore-engines true && ns package-manager set npm && yarn",
"postinstall": "husky && npx ts-patch install",
"setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && yarn",
"start": "nps",
"add": "nx g @nativescript/plugin-tools:add-package",
"add-angular": "nx g @nativescript/plugin-tools:add-angular",
Expand Down Expand Up @@ -32,13 +32,13 @@
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@nativescript/angular": "^18.0.0",
"@nativescript/core": "~8.7.0",
"@nativescript/plugin-tools": "5.3.0",
"@nativescript/types": "~8.7.0",
"@nativescript/core": "~8.8.0",
"@nativescript/plugin-tools": "5.4.1",
"@nativescript/types": "~8.8.0",
"@nativescript/webpack": "~5.0.12",
"@ngrx/effects": "^15.1.0",
"@ngrx/store": "^15.1.0",
"@ngrx/store-devtools": "^15.1.0",
"@ngrx/effects": "^18.0.0",
"@ngrx/store": "^18.0.0",
"@ngrx/store-devtools": "^18.0.0",
"@ngtools/webpack": "^18.0.0",
"@types/jest": "27.0.2",
"@types/jsan": "^3.1.2",
Expand All @@ -59,7 +59,7 @@
"rxjs": "~7.8.0",
"socketcluster-client": "^14.3.2",
"ts-node": "10.9.1",
"typescript": "~5.4.0",
"typescript": "~5.5.0",
"zone.js": "~0.14.0"
},
"lint-staged": {
Expand Down
11 changes: 9 additions & 2 deletions packages/nativescript-in-app-review/index.ios.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { Application, Device } from '@nativescript/core';
import { Application, Device, Utils } from '@nativescript/core';
import { InAppReviewCommon } from './common';

let nscAppStore: NSCAppStore;

export class InAppReview extends InAppReviewCommon {
static requestReviewPopup() {
if (+Device.sdkVersion < 14.0) {
if (Utils.SDK_VERSION >= 17 || __VISIONOS__) {
if (!nscAppStore) {
nscAppStore = NSCAppStore.new();
}
nscAppStore.requestReview();
} else if (Utils.SDK_VERSION < 14) {
SKStoreReviewController.requestReview();
} else {
SKStoreReviewController.requestReviewInScene((Application.ios.window as UIWindow).windowScene);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import StoreKit

@objc public class NSCAppStore: NSObject {
@MainActor
@objc public func requestReview() {
if #available(iOS 16.0, *) {
let windowScene = UIApplication.shared.windows.first?.windowScene
if (windowScene == nil) {
guard let scene = UIApplication.shared.connectedScenes.first,
let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,
let window = windowSceneDelegate.window else {
return
}
AppStore.requestReview(in: window!.windowScene!)
return
}

AppStore.requestReview(in: windowScene!)
}
}
}
9 changes: 9 additions & 0 deletions packages/nativescript-in-app-review/references.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/// <reference path="../../references.d.ts" />
/// <reference path="./types/play-review.d.ts" />
/// <reference path="./types/play-services-tasks.d.ts" />

declare class NSCAppStore extends NSObject {

static alloc(): NSCAppStore; // inherited from NSObject

static new(): NSCAppStore; // inherited from NSObject

requestReview(): void;
}
Loading
Loading