Set 'Send On' specific date in .Net SDK and Push Notifications

5 posts, 0 answers
  1. Carlos
    Carlos avatar
    69 posts
    Member since:
    Jun 2011

    Posted 28 Jun Link to this post

    We are using the .Net SDK to send push notifications.  Looking at the admin panel for Push Notifications in Telerik Platform we have the option send on a Specific Date.  Is this available in the .Net SDK.  So far we have not found any methods or stubs for this.  

    How about the Expires on dates too?

    Is it possible to do this in the .Net SDK or only through the admin panel in the Telerik Platform?

    Any code examples?

     

  2. Georgi Prodanov
    Admin
    Georgi Prodanov avatar
    2 posts

    Posted 30 Jun Link to this post

    Hello, Carlos,

    There is indeed a way to set a date and time for the sending of push notifications through the .NET SDK, as well as an expiry date.

    In order to do this, you need to use the "CustomProperties" property of instances of the PushNotification class. It is of type Dictionary<string, object> and the way you set the scheduled or expiry date of the notification is by adding a key with name "NotificationDate" or "ExpirationDate", respectively, and setting them to a DateTime object, or an ISO datetime string (example: "2016-06-30T10:30+02:00"). The former is the recommended use.

    Below is a simple example of the use of both properties:

    var app = new EverliveApp("<App ID here>");
    var notification = new PushNotification("The push notification message");
     
    notification.CustomProperties["NotificationDate"] = DateTime.Now.AddHours(1);
    notification.CustomProperties["ExpirationDate"] = DateTime.Now.AddHours(6);
     
    app.WorkWith().Push().Notifications().Create(notification).ExecuteSync();

    This code creates a "broadcast" type notification, scheduled to be sent an hour later, which expires in 6 hours. You can, of course, create platform specific notifications. You can use this article as a reference for that: http://docs.telerik.com/platform/backend-services/dotnet/push-notifications/send-and-target/push-notfication-object.

    Hope this helps.

    Regards,
    Georgi Prodanov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Carlos
    Carlos avatar
    69 posts
    Member since:
    Jun 2011

    Posted 30 Jun in reply to Georgi Prodanov Link to this post

    @Georgi,

    Thanks for the response.   We were just confused or misunderstanding.

    We now see it being a CustomProperty instead of a Generic Field as we thought it might be according to the documentation. But our understanding of what a Generic Field may be misunderstood too.

    http://docs.telerik.com/platform/backend-services/dotnet/push-notifications/send-and-target/push-set-options 

     

    Thanks for the info.  Much appreciated.  This will get us moving again. 

     

     

  4. Matt
    Matt avatar
    17 posts
    Member since:
    Jun 2015

    Posted 30 Jun in reply to Georgi Prodanov Link to this post

    Hey, thanks for the detailed explanation.  unfortunately, it didn't work for me.  i'm creating a new push notification with a custom model (extended per another posting about how to do custom platform messaging to iOS and how C# sdk has the iOS reference wrong and needed to be changed to 'IOS').

     

    i successfully createmessage if i do not include the NotificationDate and ExpirationDate customproperties.  so, starting from there...here's my code (newNotification is of type 'new CustomPushNotification()' which is an extension of PushNotification).  when i debug this, the msgCreate value is false/failed.  when i remove teh CustomProperties, the msgCreate is true.

     

    msg.NotificationDate = DateTime.Now;

    msg.ExpirationDate = msg.NotificationDate.addYears(100);  //note: just creating a expiration in the future for now

     

    newNotification.CustomProperties["NotificationDate"] = msg.NotificationDate;
    newNotification.CustomProperties["ExpirationDate"] = msg.ExpirationDate;

    var msgCreate = pushNotificationManager.Notifications().Create(newNotification).TryExecuteSync();

    if (msgCreate.Success)
    {

        // creation succeeded; i actually have other code here but not important

    } else {

        //creation failed

    }

  5. Georgi Prodanov
    Admin
    Georgi Prodanov avatar
    2 posts

    Posted 01 Jul Link to this post

    Hello, Matt,

    I believe you are on the right track, but do keep in mind that the expiration date cannot be farther than 4 weeks in the future, from the scheduled date of sending of the notification. 100 years is quite a bit farther and I believe this is the cause of the problem. 

    If not, please share the value of the msgCreate.Error property - it should be descriptive enough for us to have more to go on.

    Regards,
    Georgi Prodanov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top