Push Notification from Desktop application

8 posts, 0 answers
  1. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 18 Sep 2014 Link to this post

    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.
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 18 Sep 2014 Link to this post

    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.
     
  3. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 21 Sep 2014 in reply to Anton Dobrev Link to this post

    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.
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 22 Sep 2014 Link to this post

    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.
     
  5. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 22 Sep 2014 Link to this post

    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.
  6. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 23 Sep 2014 Link to this post

    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.
     
  7. Iky
    Iky avatar
    2 posts
    Member since:
    May 2014

    Posted 22 Dec 2014 in reply to Anton Dobrev Link to this post

    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?



  8. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 23 Dec 2014 Link to this post

    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.
     
Back to Top