Hop on over to Pushy.me to get started!
tns plugin add nativescript-pushy
For {N} 5 and below please use
tns plugin add nativescript-pushy@1.x
Check the source in the demo folder, or run it on your own device:
git clone https://github.com/EddyVerbruggen/nativescript-pushy
cd nativescript-pushy/src
npm i
npm run demo.ios # or demo.android
Create a file called either app.entitlements
or <YourAppName>.entitlements
(where YourAppName
is identical to the folder name of platforms/ios/YourAppName
). Here's an example.
Now reference that file from build.xcconfig
as shown here.
getDevicePushToken
import { getDevicePushToken } from "nativescript-pushy";
getDevicePushToken()
.then(token => console.log(`getDevicePushToken success, token: ${token}`))
.catch(err => console.log(`getDevicePushToken error: ${err}`));
setNotificationHandler
Since plugin version 1.1.0 the entire payload of the notification is copied to the object this handler receives,but note that it all gets copied into a data
object. So if you send for instance {"foo": "bar"}
,you can find the value "bar"
at notification.data.foo
.
import { setNotificationHandler } from "nativescript-pushy";
setNotificationHandler(notification => {
console.log(`Notification received: ${JSON.stringify(notification)}`);
});
One of the properties of the returned notification
object is foreground
, which indicates whether or notthe notification was received while the app was in either the foreground or background.
Another useful property may be appLaunchedByNotification
, which indicates whether or not the app was launchedby tapping the notification (as opposed to the app's icon). When this property is true
you may want to fi.navigate to a different route in your app.
⚠️ Do not test on a the iOS simulator as it can't receive push notifications.
RN开发环境搭建和Demo项目部署 RN开发环境搭建和Demo项目部署 安装 Node.js 新版可能不支持npm,找个支持的版本 设置 npm 镜像 npm config set registry https://registry.npm.taobao.org npm config set disturl https://npm.taobao.org/dist 安装React-Native 在r
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive
NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native
NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t
Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a
NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na
NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat
This project has moved: This project is now being maintained here: https://github.com/nativescript-community/ui-mapboxas it's become clear contrary to what I thought, I don't actually have enough time
Nativescript Hijri plugin This plugin is inspired by https://github.com/arabiaweather/hijri-date Nativescript-hijri Hijri plugin allow you to convert gregorian date to islamic hijri date. Installation