Cordova SDK quick start
Get started with the Pushwoosh Cordova SDK using this quick and simple example
Prerequisites
Anchor link toTo integrate the Pushwoosh Cordova SDK into your app, you will need the following:
Download the example project
Anchor link to# Clone the SDK repository and navigate to the example projectgit clone https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git
# Navigate to example directorycd pushwoosh-phonegap-plugin/example/newdemo/
Configure the project
Anchor link toInstall the dependencies:
npm i
Add the Pushwoosh plugin:
cordova plugin add ../../ --link --nofetch
Open www/js/index.js and update the pushwoosh.onDeviceReady
call:
pushwoosh.onDeviceReady({ appid: "XXXXX-XXXXX", projectid: "XXXXXXXXXXXXXXX"});
Replace the appid
and projectid
values with your Pushwoosh App Code and Firebase Project Number.
1. Set the Bundle Identifier
Anchor link toOpen the platforms/ios/newdemo.xcworkspace file in Xcode.
Set the Bundle Identifier for each target:
newdemo
: your app’s package name. (eg. com.example.pushwoosh)
2. Add capabilities
Anchor link toTo enable Push Notifications, you need to add certain capabilities.
In the Signing & Capabilities section, add the following capabilities:
Push Notifications
Background Modes
. After adding this capability, check the box forRemote notifications
.
3. Set the API Token
Anchor link toIn your ios/newdemo/Info.plist
set the Pushwoosh_API_TOKEN
key to the Pushwoosh Device API Token
Android
Anchor link to1. Setup google-services.json
Anchor link toCopy your google-services.json
file to the root directory of the project
2. Set the package name
Anchor link toOpen android/app/build.gradle and set the applicationId to your app’s package name. (eg. com.example.pushwoosh
)
3. Set the API Token
Anchor link toOpen your android/app/src/main/AndroidManifest.xml file and add the following metadata inside the <application>
tag:
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__" />
Replace __YOUR_PUSHWOOSH_DEVICE_API_TOKEN__
with your Pushwoosh Device API Token.
Run the project
Anchor link to- Build and run the project.
- Toggle the Register for notifications switch.
- Grant permission for push notifications. The device will be registered with Pushwoosh.
Send a push notification
Anchor link toGo back to the Pushwoosh Control Panel and send a push notification to your registered device.