NativeScript Pushy
Hop on over to Pushy.me to get started!
Installation
tns plugin add nativescript-pushy
For {N} 5 and below please use
tns plugin add nativescript-pushy@1.x
Demo app
Check the source in the demo folder, or run it on your own device:
git clone https://github.com/EddyVerbruggen/nativescript-pushycd nativescript-pushy/srcnpm inpm run demo.ios # or demo.android
Setup (iOS only)
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.
API
getDevicePushToken
; getDevicePushToken .thenconsole.log`getDevicePushToken success, token: ` .catchconsole.log`getDevicePushToken error: `;
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
.
; setNotificationHandler;
Please note..
⚠️ Do not test on a the iOS simulator as it can't receive push notifications.