This is a migrated thread and some comments may be shown as answers.

Push Notification from Desktop application

7 Answers 390 Views
.NET SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
HSLaw
Top achievements
Rank 1
HSLaw asked on 18 Sep 2014, 08:54 AM
Hi,

Can I trigger a Backend Sevices' Push Notification via a standalone desktop application?
From the documentation, it seems like Push Notification must be triggered from a Windows Apps, is that correct?

I'm looking into the possibility of sending Push Notification via Backend Services based on our data in our own SQL Server.

Thanks.

7 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 18 Sep 2014, 12:59 PM
Hi,

Yes, you can access and sent push notifications to the devices in your Telerik Backend Services project using the REST API from any programming language or framework that can make a HTTP request. For your convenience you can achieve this from an app using the .NET or JavaScript SDKs.

For instance, here is how to create a push notification for the iOS platform with the .NET SDK:
var notification = new PushNotification();
 
var iosNotificationPayload = new Dictionary<string, object>()
{
    {
            "aps",
            new Dictionary<string, object>()
            {
                { "alert", "message for iOS" },
                { "sound", "default" },
                { "badge", 1 },
            }
    },
    {
            "customData",
            new Dictionary<string, object>()
            {
                { "specialkey", "specialvalueforiOS" }
            }
    }
};
 
notification.iOS = new Telerik.Everlive.Sdk.Core.Model.System.Push.IOS.IOSNotification();
             
foreach (KeyValuePair<string, object> pair in iosNotificationPayload)
{
    notification.iOS.SetValue(pair.Key, pair.Value);
}
 
var settings = new EverliveAppSettings()
{
    ApiKey = "your-api-key",
    UseHttps = true
};
 
var app = new EverliveApp(settings);
var result = app.WorkWith().Push().Notifications().Create(notification).ExecuteSync();

Note that the example above demonstrates how to create an iOS specific notification payload. You can read more about the supported structure of the notification payload here.  More examples on how to create a platform-specific notification or a generic one with the .NET SDK are available here.

Please, let me know if you have further questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
HSLaw
Top achievements
Rank 1
answered on 22 Sep 2014, 02:31 AM
Hi Anton,

I have a requirement to send push notification based by a device's latest location. (within a certain distance from a specific point)

So when the apps is launched, the device will send their lat and lng to our server to be stored with the device UUID.

1. If I want to send push notification, is there a way to send it by targeting those UUID?
2. Alternatively, should I store the UUID as a custom parameters then I can send by using this custom parameter?

Thanks.
0
Anton Dobrev
Telerik team
answered on 22 Sep 2014, 11:53 AM
Hello,

You can target a notification based on the device uuid. Note that in the 'Devices' content type this is entered entered as "HardwareId". Note that you need to ensure that both values are the same in the devices content type in Backend Services and in your service. After you ensuret that the device registration is made in the backend you can target push notifications based on the HardwareId of the device in the following way:
// construct a filter
string[] hardwareIds = new string[] { "HardwareId1", "HardwareId2", "HardwareId3" };
 
var notificationFilter = new Dictionary<string, object>()
{
    { "PlatformType", 3 }, // specifies that only Android users will get the notification
    {
        "HardwareId", new Dictionary<string, string[]>()
                        {
                            { "$in", hardwareIds } // for all devices with a hardware id in the hardwareIds array
                        }
    }
};
 
// add the notification filter
notification.Filter = Telerik.Newtonsoft.Json.JsonConvert.SerializeObject(notificationFilter);

Alternatively, you can target the notification according to the values stored in the custom params object. Just  target, for example, the MyHardwareId stored in the custom parameters:

var notificationFilter = new Dictionary<string, object>()
{
    { "PlatformType", 3 }, // specifies that only Android users will get the notification
    {
        "Parameters.MyHardwareId", new Dictionary<string, string[]>()
                        {
                            { "$in", hardwareIds } // for all devices with a hardware id in the hardwareIds array
                        }
    }
};

Let me know if further questions arise.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
HSLaw
Top achievements
Rank 1
answered on 23 Sep 2014, 02:56 AM
Hi,

I got an error when trying to send with filter:
"The account quota is limited for this operation"

Does it mean our subscription level do not have this feature to send push by filter?

Thanks.
0
Anton Dobrev
Telerik team
answered on 23 Sep 2014, 11:57 AM
Hi,

Yes, in order to apply a filter and target a selected audience with push notifications (the Push to Segment feature) you need a Telerik Platform Professional edition or higher. You can explore the difference between the Platform subscription tiers here - just expand the "Show detailed comparison" anchor.

Let me know if further questions or suggestions arise.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Iky
Top achievements
Rank 1
answered on 23 Dec 2014, 12:09 AM
HI, this is my first post and I'm desperate for help (clarity at the very least)

I'm working on a package tracking system, the mobile app should allow clients to be able to check the location of their package. Is it possible that when a package is logged into the system (via WinForms + Azure Cloud Service), that the user be notified via push notifications?

The idea is that every time the Azure SQL record is updated, a push notification is sent to the relevant user. 

Is it possible? if so.. do i need to study rocket science to achieve it?



0
Anton Dobrev
Telerik team
answered on 23 Dec 2014, 12:26 PM
Hi Iky,

Thank you for posting to the Telerik Developer Forums.

In brief, yes, this is possible.

Firstly, you need to register the user for push notifications with custom parameters that can uniquely identify the information the user is interested in. You can read more about this in the following Telerik Backend Services documentation article.

Then, when an item is successfully updated from the WinForms app, send a notification to Backend Services using the .NET SDK and apply a filter that targets the given user, based on the custom parameters in the device registration.

I hope that this helps. Do not hesitate to write us back should you have any further questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
.NET SDK
Asked by
HSLaw
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
HSLaw
Top achievements
Rank 1
Iky
Top achievements
Rank 1
Share this question
or