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

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

4 Answers 47 Views
Push Notifications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carlos
Top achievements
Rank 1
Carlos asked on 28 Jun 2016, 09:25 PM

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?

 

4 Answers, 1 is accepted

Sort by
0
Georgi Prodanov
Telerik team
answered on 30 Jun 2016, 12:12 PM
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.
 
0
Carlos
Top achievements
Rank 1
answered on 30 Jun 2016, 02:25 PM

@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. 

 

 

0
Matt
Top achievements
Rank 1
answered on 30 Jun 2016, 04:46 PM

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

}

0
Georgi Prodanov
Telerik team
answered on 01 Jul 2016, 03:43 PM
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.
 
Tags
Push Notifications
Asked by
Carlos
Top achievements
Rank 1
Answers by
Georgi Prodanov
Telerik team
Carlos
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or