Skip to content

Commit c833eb7

Browse files
author
Jérémy Magrin
committed
Merge branch 'develop'
2 parents 220ddba + 693bdad commit c833eb7

File tree

11 files changed

+540
-1
lines changed

11 files changed

+540
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
13+
# Xcode
14+
#
15+
build/
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
xcuserdata
25+
*.xccheckout
26+
*.moved-aside
27+
DerivedData
28+
*.hmap
29+
*.ipa
30+
*.xcuserstate
31+
project.xcworkspace
32+
33+
34+
# Android/IntelliJ
35+
#
36+
build/
37+
.idea
38+
.gradle
39+
local.properties
40+
*.iml
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
# react-native-app-store-review
1+
2+
# react-native-app-store-review
3+
4+
![rsz_ios-103-beta-1-note-application](https://cloud.githubusercontent.com/assets/3551795/25345288/f78ff17e-2914-11e7-9939-8d2f6897bf7e.jpg)
5+
6+
7+
This library allow you to print the new iOS 10.3 rate pop-up.
8+
If your users use a version of iOS higher than 8.0 but lesser than 10.3 a new view within the app is pushed with the app store page of your app.
9+
And if your user got an iOS version lesser than 8.0, it will be redirected on the app store in the write review section of your app.
10+
11+
## Getting started
12+
13+
`$ npm install react-native-app-store-review --save`
14+
15+
### Mostly automatic installation
16+
17+
`$ react-native link react-native-app-store-review`
18+
19+
### Manual installation
20+
21+
22+
#### iOS
23+
24+
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
25+
2. Go to `node_modules``react-native-app-store-review` and add `RNAppStoreReview.xcodeproj`
26+
3. In XCode, in the project navigator, select your project. Add `libRNAppStoreReview.a` to your project's `Build Phases``Link Binary With Libraries`
27+
4. Run your project (`Cmd+R`)<
28+
29+
#### Android
30+
31+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
32+
- Add `import com.reactlibrary.RNAppStoreReviewPackage;` to the imports at the top of the file
33+
- Add `new RNAppStoreReviewPackage()` to the list returned by the `getPackages()` method
34+
2. Append the following lines to `android/settings.gradle`:
35+
```
36+
include ':react-native-app-store-review'
37+
project(':react-native-app-store-review').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-app-store-review/android')
38+
```
39+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
40+
```
41+
compile project(':react-native-app-store-review')
42+
```
43+
44+
## Usage
45+
```javascript
46+
import AppStoreReview from 'react-native-app-store-review';
47+
48+
AppStoreReview.requestReview('1234567890'); // Change to your app store id
49+
```

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Index from './src/index';
2+
3+
export default Index;

ios/RNAppStoreReview.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// RNAppStoreReview.h
3+
//
4+
// Created by Jérémy Magrin on 24/04/2017.
5+
// Copyright © 2017 Jérémy Magrin. All rights reserved.
6+
//
7+
8+
#ifndef AppRate_h
9+
#define AppRate_h
10+
11+
#if __has_include("RCTBridgeModule.h")
12+
#import "RCTBridgeModule.h"
13+
#else
14+
#import <React/RCTBridgeModule.h>
15+
#endif
16+
17+
#import <StoreKit/StoreKit.h>
18+
19+
20+
@interface RNAppStoreReview: NSObject <RCTBridgeModule, SKStoreProductViewControllerDelegate>
21+
22+
@end
23+
24+
#endif /* AppRate_h */

ios/RNAppStoreReview.m

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// RNAppStoreReview.m
3+
//
4+
// Created by Jérémy Magrin on 24/04/2017.
5+
// Copyright © 2017 Jérémy Magrin. All rights reserved.
6+
//
7+
8+
#import "RNAppStoreReview.h"
9+
10+
#import <Foundation/Foundation.h>
11+
12+
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
13+
14+
@implementation RNAppStoreReview
15+
16+
RCT_EXPORT_MODULE();
17+
18+
- (dispatch_queue_t) methodQueue
19+
{
20+
return dispatch_get_main_queue();
21+
}
22+
23+
- (UIViewController*) getRootVC {
24+
UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
25+
while (root.presentedViewController != nil) {
26+
root = root.presentedViewController;
27+
}
28+
29+
return root;
30+
}
31+
32+
- (void) openStoreProductWithiTunesItemIdentifierWithinApp:(NSString *) appIdentifier {
33+
UIViewController *root = [self getRootVC];
34+
35+
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
36+
storeViewController.delegate = self;
37+
38+
NSDictionary *parameters = @{ SKStoreProductParameterITunesItemIdentifier: appIdentifier };
39+
40+
[storeViewController loadProductWithParameters:parameters completionBlock:^(BOOL result, NSError *error) {
41+
if (result) {
42+
[root presentViewController:storeViewController animated:YES completion:nil];
43+
} else {
44+
NSLog(@"ERROR WITH STORE CONTROLLER %@\n", error.description);
45+
//redirect to app store
46+
[self openStoreProductWithiTunesItemIdentifier:appIdentifier];
47+
}
48+
}];
49+
}
50+
51+
- (void) openStoreProductWithiTunesItemIdentifier:(NSString *) appIdentifier {
52+
NSString *strUrl = [NSString stringWithFormat:@"%@%@%@", @"itms-apps://itunes.apple.com/app/id", appIdentifier, @"?action=write-review"];
53+
NSURL *url = [NSURL URLWithString: strUrl];
54+
55+
if ([[UIApplication sharedApplication] canOpenURL:url]) {
56+
[[UIApplication sharedApplication] openURL:url];
57+
}
58+
}
59+
60+
- (void) productViewControllerDidFinish:(SKStoreProductViewController*)viewController {
61+
[viewController dismissViewControllerAnimated:YES completion:nil];
62+
}
63+
64+
RCT_EXPORT_METHOD(requestReview:(NSString *) appIdentifier)
65+
{
66+
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.3")) {
67+
[SKStoreReviewController requestReview];
68+
} else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
69+
[self openStoreProductWithiTunesItemIdentifierWithinApp:appIdentifier];
70+
} else {
71+
[self openStoreProductWithiTunesItemIdentifier:appIdentifier];
72+
}
73+
}
74+
75+
@end

ios/RNAppStoreReview.podspec

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Pod::Spec.new do |s|
3+
s.name = "RNAppStoreReview"
4+
s.version = "0.0.1"
5+
s.summary = "RNAppStoreReview"
6+
s.description = <<-DESC
7+
Rate on app store inside your app
8+
DESC
9+
s.homepage = ""
10+
s.license = "MIT"
11+
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
12+
s.author = { "author" => "[email protected]" }
13+
s.platform = :ios, "7.0"
14+
s.source = { :git => "https://github.com/magrinj/react-native-app-store-review.git", :tag => "master" }
15+
s.source_files = "RNAppStoreReview/**/*.{h,m}"
16+
s.requires_arc = true
17+
18+
19+
s.dependency "React"
20+
#s.dependency "others"
21+
22+
end

0 commit comments

Comments
 (0)