Use Onesignal Push notifications in Telerik Platform Project

Since Telerik only provides filters for pushmessaging starting at the $149 monthly subscription, I was looking for a good plugin to use in my cordova application.

I found the OneSignal plugin, it looks great, and has an API, so I can send pushmessages from my webserver.In order to use the plugin in telerik you will need to first:

  • create a free onesignal account
  • create an app inside your account, and note your application id for usage in the mobile app


download the OneSignal Cordova SDK from Github just click clone or download button, and hit download zip.

After you have downloaded the zip file you can import it into your telerik project by going to code->plugins and click the import button and locating the downloaded zipfile:
If all went well you should be able to see the package at the bottom of the plugins page:

For the plugin to work you need to add this code to the bottom of your app.js:

var  notificationOpenedCallback= function(jsonData) {
//Do some things here
// Set your iOS Settings
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = true;
iosSettings["kOSSettingsKeyInAppLaunchURL"] = true;
window.plugins.OneSignal.startInit("your-app-id-code-goes-here", "")

I am currently testing on IOS, if you need android support as well you need to add your google project id to the second parameter of startInit().

This will be enough to send a testmessage to your device, and get you started.
When you start the app for the first time, you should get a permission request to send push requests, if you agree, you will be able to see your mobile device in the onesignal backend, and send pushmessages to it.

Please keep in mind
the telerik simulator doesnt support the push notification plugin, so to test this out you need to build and deploy it to your account.
For ios you need to have your provisioning profile setup and have a certificate created for the app, that allows for push messaging.



Leave a Reply

Your email address will not be published.