react-native-in-app-review
Advanced tools
Comparing version 2.1.8 to 3.1.0
@@ -1,5 +0,5 @@ | ||
declare module "react-native-in-app-review"; | ||
declare module 'react-native-in-app-review'; | ||
export function RequestInAppReview(): void; | ||
export function RequestInAppReview(): Promise<void>; | ||
export function isAvailable(): boolean; |
40
index.js
@@ -1,25 +0,25 @@ | ||
import React from "react"; | ||
import {NativeModules, Platform} from 'react-native'; | ||
import { NativeModules, Platform } from "react-native"; | ||
const {InAppReviewModule, RNInAppReviewIOS} = NativeModules; | ||
const { InAppReviewModule, RNInAppReviewIOS } = NativeModules; | ||
const isAvailable = !!RNInAppReviewIOS && RNInAppReviewIOS.isAvailable; //ios version check | ||
function isVersionAvailable() { | ||
if (Platform.OS === "android" && Platform.Version >= 21) { | ||
function isModuleAvailable() { | ||
if (Platform.OS === 'android') { | ||
if (!InAppReviewModule) { | ||
throw new Error( | ||
"InAppReview native module not available, did you forget to link the library?" | ||
'InAppReview native module not available, did you forget to link the library?', | ||
); | ||
} | ||
return true; | ||
} else if (Platform.OS === "ios") { | ||
} else if (Platform.OS === 'ios') { | ||
if (!RNInAppReviewIOS) { | ||
throw new Error( | ||
"InAppReview native module not available, did you forget to link the library?" | ||
'InAppReview native module not available, did you forget to link the library?', | ||
); | ||
} | ||
return isAvailable; | ||
} else return false; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -29,6 +29,8 @@ | ||
static RequestInAppReview() { | ||
if (Platform.OS === "android" && isVersionAvailable()) { | ||
InAppReviewModule.show(); | ||
} else if (Platform.OS === "ios" && isVersionAvailable()) { | ||
RNInAppReviewIOS.requestReview(); | ||
if (isModuleAvailable()) { | ||
if (Platform.OS === 'android') { | ||
return InAppReviewModule.show(); | ||
} else { | ||
return RNInAppReviewIOS.requestReview({}); | ||
} | ||
} | ||
@@ -38,4 +40,10 @@ } | ||
static isAvailable() { | ||
return isVersionAvailable(); | ||
if (Platform.OS === 'android' && Platform.Version >= 21) { | ||
return true; | ||
} else if (Platform.OS === 'ios') { | ||
return isAvailable; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
{ | ||
"name": "react-native-in-app-review", | ||
"version": "2.1.8", | ||
"version": "3.1.0", | ||
"description": "react native in app review, to rate on Play store, App Store, Generally, the in-app review flow (see figure 1 for play store, figure 2 for ios) can be triggered at any time throughout the user journey of your app. During the flow, the user has the ability to rate your app using the 1 to 5 star system and to add an optional comment for play store only. Once submitted, the review is sent to the Play Store or App store and eventually displayed.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test:package": "jest --ci --coverage __tests__/InAppReview-test.js InAppReviewWithoutNativeModules-test.js", | ||
"test:example": "cd Example && jest --ci --coverage", | ||
"test": "npm run test:package && npm run test:example", | ||
"test:ci": "jest --ci --coverage", | ||
"lint": "eslint . --fix" | ||
}, | ||
@@ -37,3 +41,5 @@ "keywords": [ | ||
"README.md", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"index.js", | ||
"__tests__" | ||
], | ||
@@ -49,3 +55,40 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/MinaSamir11/react-native-in-app-review#readme" | ||
"homepage": "https://github.com/MinaSamir11/react-native-in-app-review#readme", | ||
"devDependencies": { | ||
"@babel/core": "^7.8.4", | ||
"@babel/runtime": "^7.8.4", | ||
"@react-native-community/eslint-config": "^1.1.0", | ||
"@testing-library/react-hooks": "^5.0.0", | ||
"babel-jest": "^25.1.0", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^6.5.1", | ||
"eslint-plugin-unused-imports": "^1.0.1", | ||
"husky": "^4.3.8", | ||
"jest": "^25.1.0", | ||
"lint-staged": "^10.5.3", | ||
"metro-react-native-babel-preset": "^0.59.0", | ||
"react": "16.13.1", | ||
"react-native": "0.63.4", | ||
"react-test-renderer": "16.13.1" | ||
}, | ||
"jest": { | ||
"preset": "react-native", | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>/Example/" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/jest.setup.js" | ||
] | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged -v && npm run test:ci" | ||
} | ||
} | ||
} |
@@ -7,2 +7,6 @@ # react-native-in-app-review | ||
![Travis (.com) branch](https://img.shields.io/travis/com/MinaSamir11/react-native-in-app-review/master) | ||
[![Coverage Status](https://coveralls.io/repos/github/MinaSamir11/react-native-in-app-review/badge.svg)](https://coveralls.io/github/MinaSamir11/react-native-in-app-review) | ||
The Google Play In-App Review API, App store rating API lets you prompt users to submit Play Store or App store ratings and reviews without the inconvenience of leaving your app or game. | ||
@@ -66,3 +70,3 @@ | ||
<summary>iOS details</summary> | ||
### Using [CocoaPods](https://cocoapods.org/) | ||
@@ -135,3 +139,3 @@ | ||
```javascript | ||
import InAppReview from "react-native-in-app-review"; | ||
import InAppReview from 'react-native-in-app-review'; | ||
``` | ||
@@ -146,5 +150,49 @@ | ||
// trigger UI InAppreview | ||
InAppReview.RequestInAppReview(); | ||
InAppReview.RequestInAppReview() | ||
.then((hasFlowFinishedSuccessfully) => { | ||
// when return true in android it means user finished or close review flow | ||
console.log('InAppReview in android', hasFlowFinishedSuccessfully); | ||
// when return true in ios it means review flow lanuched to user. | ||
console.log( | ||
'InAppReview in ios has lanuched successfully', | ||
hasFlowFinishedSuccessfully, | ||
); | ||
// 1- you have option to do something ex: (navigate Home page) (in android). | ||
// 2- you have option to do something, | ||
// ex: (save date today to lanuch InAppReview after 15 days) (in android and ios). | ||
// 3- another option: | ||
if (hasFlowFinishedSuccessfully) { | ||
// do something for ios | ||
// do something for android | ||
} | ||
// for android: | ||
// The flow has finished. The API does not indicate whether the user | ||
// reviewed or not, or even whether the review dialog was shown. Thus, no | ||
// matter the result, we continue our app flow. | ||
// for ios | ||
// the flow lanuched successfully, The API does not indicate whether the user | ||
// reviewed or not, or he/she closed flow yet as android, Thus, no | ||
// matter the result, we continue our app flow. | ||
}) | ||
.catch((error) => { | ||
//we continue our app flow. | ||
// we have some error could happen while lanuching InAppReview, | ||
// Check table for errors and code number that can return in catch. | ||
console.log(error); | ||
}); | ||
``` | ||
# Error could happen and code number | ||
| Error Name | Code Number | Description | iOS | Android | | ||
| ----------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------- | | ||
| ERROR_DEVICE_VERSION | 21 | This Device not supported to lanuch InAppReview | ✅ | ✅ | | ||
| GOOGLE_SERVICES_NOT_AVAILABLE | 22 | This Device doesn't support google play services | ❌ | ✅ | | ||
| [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. | ❌ | ✅ | | ||
# + Android Notes: | ||
@@ -151,0 +199,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
39894
16
332
0
255
15
1