Skip to content

nativescript-community/capacitor-plugins

Repository files navigation

npm version

All Contributors

@nativescript-community/capacitor-plugins

✅ This repository is test repository, and not release @nativescript-community/capacitor-plugins now.

👊 Try this project

Please clone, and npm link in your local.

% git clone [email protected]:nativescript-community/capacitor-plugins.git
% cd capacitor-plugins && npm install
% npm link

📱 Install in your Capacitor Project

PreInstall in your project

% npm install @capacitor/cli@next --save-dev
% npm install @capacitor/core@next --save
% npm install @nativescript/capacitor

Install

% npm install --save @nativescript-community/capacitor-plugins

Change your project

1. Add src/nativescript/index.ts

Add the following code:

  import '@nativescript/capacitor/bridge';
+ import * as Plugins from '@nativescript-community/capacitor-plugins';

+ native = Object.assign(native, Plugins);
...

Example demo is here.

2. Change src/native-custom.d.ts

Replace the following code:

+ import type { pluginsGlobal } from '@nativescript-community/capacitor-plugins/src/interfaces';

  declare module '@nativescript/capacitor' {
    export interface customNativeAPI extends nativeCustom {}
  }

  /**
   * Define your own custom strongly typed native helpers here.
   */
- export interface nativeCustom {
+ export interface nativeCustom extends pluginsGlobal {

Example demo is here.

Usage

Usage Example demo is here..

1. brightness(value: number)

You can change device brightness (1〜10). This is official example code.

import { native } from '@nativescript/capacitor';

native.brightness(1);

2. rateMyApp()

You can allow users to rate the app from inside the application.

iOS

No additional configurations are required for iOS. However, for now it supports iOS version 10.3 and later.

Android

Before start using this function add next lines to the dependencies section of your android/app/build.gradle

implementation "androidx.appcompat:appcompat:1.2.0"
implementation 'com.google.android.play:core:1.10.0'

You can read more about how to import Google Play Core Library into your project here

In-app reviews only work on Android devices (phones and tablets) running Android 5.0 (API level 21) or higher that have the Google Play Store installed and on Chrome OS devices that have the Google Play Store installed.

Important: your app should be published for at least internal testing. Read more about it in this SO answer

Usage

import { native } from '@nativescript/capacitor';
native.rateMyApp();

Demo Code

You can check Native Console Log. This is official example code.

import { native } from '@nativescript/capacitor';

native.dreamBig();

And Launch Native Modal View. This is official example code.

import { native } from '@nativescript/capacitor';

native.openNativeModalView();

Option

If you want use some plugin only:

You should select plugin and import.

src/nativescript/index.ts:

import { brightness } from '@nativescript-community/capacitor-plugins';
native = Object.assign(native, {
  brightness,
});

src/native-custom.d.ts:

import type { IBrightness } from '@nativescript-community/capacitor-plugins/src/interfaces';
export interface nativeCustom extends IBrightness {
  dreamBig: () => NativeProperty<string>;
  openNativeModalView: () => void;
}

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Sergey Mell

💻

About

Community plugin for `NativeScript for Capacitor`

Resources

Stars

Watchers

Forks

Packages

No packages published