arashnorouzi / Moon-APNS

A free open source c# library for sending Apple Push Notifications in any .net application.
http://arashnorouzi.wordpress.com
90 stars 45 forks source link

how to add custom payload formate in c# getting issue..? #19

Closed Rajafkvp closed 9 years ago

Rajafkvp commented 9 years ago

By default payload {"aps":{"alert":"Message","badge":1,"sound":"default"}}

with this i need to add one more array object in c# how i can add that i need the output like this {"aps":{"alert":"Message","badge":1,"sound":"default"},"Vi":{"id":1,"name":"raj","pp":"Need to talk"}}

I am trying like this below code

object[] objc = {new { id = 1, nm = "raj", pp = "visit" }}; string msgData = new JavaScriptSerializer().Serialize(objc); string[] resultArray = Array.ConvertAll(objc, x => x.ToString()).ToArray();

payload1.CustomItems.Add("Vi", resultArray())

the output i am getting is like this below but in that the array object it come with quotes {"aps":{"alert":"Message","badge":1,"sound":"default"},"Vi":"{ id = 1, nm = raj, pp = visit }"}

so i need a output like this

{"aps":{"alert":"Message","badge":1,"sound":"default"},"Vi":{ "id" : 1, "nm" :"raj", "pp" : "visit" }}