GetNewChannel function

Jun 20, 2015 at 12:22 AM
Hi!, excellent WindowsPhoneClass! excuse me, I have a question... in your Documentation you put on the "How to send a Toast notification" a call to a function called GetNewChannel, but it doesn't exist on your code... can you help me with that? how can i get a new channel?

Thanks! and sorry for my bad english
Coordinator
Jun 20, 2015 at 10:46 AM
Edited Jun 20, 2015 at 10:50 AM
Hello jare0590,
How specified this class just "speaks" with the Windows WNS.

The GetNewChannel function I've used is an abstract function that get the channel from my datasource (a database, a serialized file, etc).
I'll try to show you a scenario with a database.
In according with the push notification system on Windows you have:
(1)
Device: Open channel and send to your service --------------------------> Your Service: Memorize the new channel on database

Now, with the hypothesis that your service is already authorized with WNS, you need to send a noitification.

So, you can create a your function (GetNewChannel or whatever name you want) that return a new channel from database.
Ergo:
(2)
MyDatabase: GetNewChannel ------->WindowsNotification: Set notification type and send it to the channel --------------------------> WNS: send push notification

In my example, GetNewChannel hypothesis is that return me a new channel, but you can implement it however you want.
For example you can use it to return a list of channel and iterate it.
$channelArray = GetChennels();
foreach($cha in $channelArray)
{
           $Notifier->Send($cha,WindowsNotification\TemplateToast::ToastText01("HELLO!"));
}
I don't know if I have made a good explanation, but GetChannel for me is just an abstract function to show how use the WindowsNotification.

If you need some other help, please let me know.

If you need an example of (1), please let me know, I can send you an example script in Universal app 8.1
Jun 22, 2015 at 4:25 PM
Thank you Andreabbondanza

Now I see more clearly, but if you can help me sending me the script example that will be very helpful for me
Coordinator
Jun 22, 2015 at 11:54 PM
Ok jare0590
Tomorrow I'll prepare you a device-side script (a blank app that open channel at start)
and an example of php script that use the notification class with a channel.
Coordinator
Jun 23, 2015 at 5:51 PM
Hi hare0590,
Here you can see an example:
https://mega.nz/#!S1MjHIbB!7FlpT6r2Cw5e5hEGRYVS5RqWkvK9lufUMJh8X7N-eUY

This is an universal app project. The example run under the Windows phone 8.1 project.
The code you need to check is in the notification Helper in project shared folder.

In the project shared folder there is also a php example script to use in your service (like example, is not for production!).
Hope this can help you, have a nice day!
Jun 23, 2015 at 10:08 PM
Hi Andreabbondanza!

Excellent! Thank you very much, I really appreciate it!

We still in contact.