Skip to content

Commit

Permalink
Rewrite to use latest recommended plugin structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodonisko committed Sep 26, 2021
1 parent 8593e11 commit ef0bcd0
Show file tree
Hide file tree
Showing 46 changed files with 2,461 additions and 557 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
23 changes: 12 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# node files
dist/
node_modules/
dist
node_modules

# iOS files
Pods
Podfile.lock
Build
xcuserdata

Expand All @@ -12,7 +13,7 @@ xcuserdata



# Based on Android gitignore template: https://github.com/github/gitignore/blob/master/Android.gitignore
# Based on Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore

# Built application files
*.apk
Expand All @@ -25,28 +26,28 @@ xcuserdata
*.class

# Generated files
bin/
gen/
out/
bin
gen
out

# Gradle files
.gradle/
build/
.gradle
build

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/
proguard

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/
.navigation

# Android Studio captures folder
captures/
captures

# IntelliJ
*.iml
Expand Down
60 changes: 0 additions & 60 deletions .npmignore

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Contributing

This guide provides instructions for contributing to this Capacitor plugin.

## Developing

### Local Setup

1. Fork and clone the repo.
1. Install the dependencies.

```shell
npm install
```

1. Install SwiftLint if you're on macOS.
```shell
brew install swiftlint
```
### Scripts
#### `npm run build`
Build the plugin web assets and generate plugin API documentation using [`@capacitor/docgen`](https://github.com/ionic-team/capacitor-docgen).
It will compile the TypeScript code from `src/` into ESM JavaScript in `dist/esm/`. These files are used in apps with bundlers when your plugin is imported.
Then, Rollup will bundle the code into a single file at `dist/plugin.js`. This file is used in apps without bundlers by including it as a script in `index.html`.
#### `npm run verify`
Build and validate the web and native projects.
This is useful to run in CI to verify that the plugin builds for all platforms.
#### `npm run lint` / `npm run fmt`
Check formatting and code quality, autoformat/autofix if possible.
This template is integrated with ESLint, Prettier, and SwiftLint. Using these tools is completely optional, but the [Capacitor Community](https://github.com/capacitor-community/) strives to have consistent code style and structure for easier cooperation.
## Publishing
There is a `prepublishOnly` hook in `package.json` which prepares the plugin before publishing, so all you need to do is run:
```shell
npm publish
```
> **Note**: The [`files`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#files) array in `package.json` specifies which files get published. If you rename files/directories or add files elsewhere, you may need to update it.
28 changes: 16 additions & 12 deletions CapacitorRateApp.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
require 'json'

Pod::Spec.new do |s|
s.name = 'CapacitorRateApp'
s.version = '1.0.0'
s.summary = 'Rate your app in stores'
s.license = 'MIT'
s.homepage = '-'
s.author = 'Daniel Suchy'
s.source = { :git => '-', :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.dependency 'Capacitor'
end
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'CapacitorRateApp'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
end
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

34 changes: 13 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Let users rate your app using native rate app dialog for both Android and iOS.

Please be aware of iOS limitations, [read below](#ios-limitations---important)!
**Please be aware of limitations for your platform, it's reason in 99% cases when dialog is not showing. Platform details: [iOS limitations](#ios-limitations---important), [Android limitations](#android-limitations---important).**

![iOS rate popup](https://i2.wp.com/9to5mac.com/wp-content/uploads/sites/6/2017/01/simulator-screen-shot-25-jan-2017-12-47-41.jpg?resize=800%2C0&quality=82&strip=all&ssl=1)

Expand All @@ -20,23 +20,17 @@ $ yarn add capacitor-rate-app

Don't forget run `cap sync` command afterwards.

## Android configuration
## Usage

In file `android/app/src/main/java/**/**/MainActivity.java`, add the plugin to the initialization list:
```js
import { RateApp } from 'capacitor-rate-app';

```java
import com.capacitor.rateApp.CapacitorRateApp;
[...]
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
[...]
add(CapacitorRateApp.class);
[...]
}});
RateApp.requestReview();
```

## iOS configuration
## Demo

No configuration needed, works out-of-box.
For more detailed example check demo app [check demo app](https://github.com/Nodonisko/rate-app-demo).

## iOS limitations - IMPORTANT!

Expand All @@ -46,17 +40,15 @@ No configuration needed, works out-of-box.
4. **No matter how many times you call the API, the system will only show up to a maximum of 3 prompts to the same user in a 365-day period.**
5. The App Store defaults to showing ratings and reviews only for your app’s most recent version.
6. The User can turn off this in settings.
7. Apple might mandate this flow in future.
7. Apple might mandate this flow in future.
8. **In dev env, dialog is always shown, but you can't submit review.**

## Usage
## Android limitations - IMPORTANT!

```js
import { RateApp } from "capacitor-rate-app";
This is copied from [official docs:](https://developer.android.com/guide/playcore/in-app-review#quotas)

RateApp.requestReview()
```
_To provide a great user experience, Google Play enforces a time-bound quota on how often a user can be shown the review dialog. Because of this quota, calling the launchReviewFlow method more than once during a short period of time (for example, less than a month) might not always display a dialog._

## Demo
_Because the quota is subject to change, it's important to apply your own logic and target the best possible moment to request a review. For example, you should not have a call-to-action option (such as a button) to trigger the API, as a user might have already hit their quota and the flow won’t be shown, presenting a broken experience to the user. For this use case, redirect the user to the Play Store instead._

For more detailed example check demo app [check demo app](https://github.com/Nodonisko/rate-app-demo).
_Note: The specific value of the quota is an implementation detail, and it can be changed by Google Play without any notice._
6 changes: 0 additions & 6 deletions android/.classpath

This file was deleted.

File renamed without changes.
23 changes: 0 additions & 23 deletions android/.project

This file was deleted.

2 changes: 0 additions & 2 deletions android/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

28 changes: 18 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
}

buildscript {
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:4.2.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -28,6 +35,10 @@ android {
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
Expand All @@ -40,12 +51,9 @@ repositories {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation 'com.google.android.play:core:1.8.2'

testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
}

Loading

0 comments on commit ef0bcd0

Please sign in to comment.