Windows 8 And Windows Phone Push Notifications Using Azure - c#

I've looked into Azure Mobile Services and found its great but does not give me the flexibility I want (Node.js also leaves a bad taste in my mouth coming from C#).
I was using periodic update notifications in Windows 8 and already have an ASP.NET Web API project supplying tile images and tile xml content. I was hoping to use an Azure Worker Role with Azure storage tables for Push Notifications for Windows 8 and Windows Phone.
I found this example but it seems to be for VS2012 Release Preview. I can't find an updated version or any other samples to work with. In particular I want my service to support both Windows 8 and Windows Phone.
http://watwindows8.codeplex.com/wikipage?title=Push%20Notification%20Worker%20Sample
If anyone can outline the references/nuget packages I need. It would be a great help.
EDIT:
Jim O'Neil's blog is a good starting point. I need to use a Azure Worker Role because I want to send my notifications periodically.
I also found the WnsRecipe NuGet package for sending push notifications from the server. Jim O'Neil solution is just as good.
Finally, to save a bit of time, I was hoping to avoid writing data acess code for registering apps channel ID's to a table on the server. The Azure Mobile Services MobileServiceClient class is a great solution to this as it lets you do all of this with a couple of lines of code. The table is available through REST services. However, questions remain:
Can I continue using the Mobile Services Table Storage MobileServiceClient with my app and Azure Worker Role or do I have to use Azure Table Storage?
If I can use MobileServiceClient, how do I access the table from my Azure Worker Role?
If I have to use Azure Table Storage which also provides a REST service for free, how can I access the table from my Windows 8 app?

Windows Azure Service Bus just released a new feature that allows to push Windows 8 (and iOS) notifications from C# back-ends (and soon from Mobile Services too), with no need top handle ChannelURIs at all.
Take a look at: http://channel9.msdn.com/Shows/Cloud+Cover/Episode-100-Introduction-to-the-Windows-Azure-Service-Bus-Notification-Hubs
Windows 8 code walkthrough: http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-Windows-8-Edition
If you try it, let me know what you think!

Strictly speaking, no NuGet packages are needed, they are just wrappers for functionality (it's all REST/OAuth under the covers) to make your life easier. As you observed, the Windows Azure Toolkit for Windows 8 and Windows Phone has been somewhat supplanted by Windows Azure Mobile Services.
If you want to do it all yourself, you can check out a three part blog series I did on using Azure Web Sites for Push Notifications. It's Web Sites, not Web Roles, but that part is fairly interchangeable; although, I'd say that Web Sites are going to be a far more economical option here unless you already have a service implemented that you are using.
I don't have Windows Phone incorporated into that series, and Windows Phone does use a slightly different notification mechanism from Windows 8, but that's on my to-do list, and hopefully what is there will get you going in the right direction.

When you use the MobileServiceClient to store data in Mobile Services, you are actually storing your data in a SQL Azure database. You have a number of options when it comes to accessing this data from your worker role.
Connect directly using a SQL client. This could be Entity Framework, a different ORM, or even raw ADO.NET. You can get the connection string for your database by selecting it in the Azure portal. On the dashboard tab there is an option to show connection strings.
Use a client library to access the data via Mobile Services. Unfortunately we do not have an official SDK that can be used from a worker role yet but the good news is that there is an unofficial package on NuGet
Access the data directly via the HTTP endpoint that Mobile Services provides by making HTTP requests. The API is documented here.

Related

Can Microsoft On-Premises Data Gateways be accessed from a non-Power client [duplicate]

I have set up an Azure On-Premise Data Gateway by following these instructions here. I also tested accessing through Logic Apps following these instructions.
However, I don't want to use Logic Apps. Are there any client libraries where I can directly access the gateway instead of only being able to talk through the Logic Apps workflow schema?
All I'm trying to do is stream files from file paths on-prem using C#.
Unfortunately, there is no such DotNet SDK or any another SDK is available for you as of now which might help in On-Prem Data GateWay accessing.
As of now, you can use only the Power BI, Microsoft Flow, Logic Apps, and PowerApps services that may help you to securely transfer the data between On-Prem and Cloud.
There is also some list of an available data source for on-prem data gateway. You can find it here
If you are trying to move on-Prem SQL server to Azure SQL Database then ADF would be helpful
So finally, you would need to continue with your Logic Apps or other services which currently support the onPrem Data Gateway
The gateway is built on top of Azure Relay, which you can use directly. Hybrid connections are also available in App Service.

Notification on multiple android phones using GCM and web services + database data

I am developing an app for selling of products, but I am stuck up in a place where I am not understanding how to give notifications to android phone from database change(insert or update on that table) for new products availble and offers like discounts, schemes etc.
I followed androidhive.com and javapapers.com for the GCM push notifications concept and it is sort of clear:
PHP or C# or Java web service
MySQL or SQLServer Database
GCM
Android phone
The statement for my problem would be "App should receive push notifications for new products, and offers and discounts given by the person-in-charge for it"
My assumption for this problem is:The "offers and discounts" would be "inserted" to a table(tbl_products) in the database and same goes for new products, "inserted" into a table(tbl_offers) in the database.
As soon as that "insertion" is done, the web service (php and c#), which I don't know how it should know, but gets to know about the change and informs GCM, and GCM sends the notification to the respective users.
The logic behind this is not familiar to me. I would greatly appreciate it if someone would help me with the logic and point me in the right direction of the coding for Android and web service. Thank you in advance.
I have been there ,done that! The way you should to proceed is:-
Create your website backend, a web service connected to a database(You need to use and know SQL for this part). Define your database accordingly. PHP is the easiest way to get started. Look at the GCM backend tutorials on Google.
Create your mobile application which has google play services enabled to use GCM. Implement GCM in your android app following the tutorial at the Official Android Developer website. You need to create an XMPP or RESTful service to communicate with your server. Your server needs to support XMPP to communicate better with Google. HTTP(GET/POST/PUT) is a dirty alternative to get working when you do not have a VPS setup for languages like Java(Most hosting companies allow only PHP,HTML,JavaScript etc on shared hosting).Depending on your scale of operation you may have to rent a Virtual Private Server(VPS) for your web service.
Create a private backend application(can be web or a desktop application) to upload your offers and so on. Examples on www.androhive.info
Make sure you got steps 1,2,3 correct.
Test your mobile application.
The idea can be pictorially represented as :-

Azure Push notifications without Azure Mobile project?

I'm building a Phonegap application that uses a server backend built with .net MVC 5 & Web API2. It's hosted on Azure cloud services and all is working well.
I now need to add some functionality to send push notifications when certain events happen. I've set up a Mobile Service on Azure and configured it for IOS (I will add Android when I have it working) and I now need to start coding the functionality.
I was planning on storing the device registration Id in my own Database and writing a simple class/service that consumes the Azure Mobile Services API to send the push notification. I've spent the last few hours reading up on this and all of the tutorials involve creating a new Azure Mobile Services project which uses Azure Table storage and configuring that (https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn629482.aspx).
I'd like to avoid this as it seems like overkill and it's yet another thing I'll need to deploy and manage.
Does anyone know if it is it possible to just add the required references to my existing cloud services project and do it the way I proposed?
Many thanks,
John
Since you already have a working backend, you don't need a Mobile Service just to send Push Notifications. Take a look at Azure Notification Hubs. You can call it via REST from your MVC, or use the Azure Service Bus NuGet package.
Take a look at this introduction: Get started with Notification Hubs
Note that you will need two different Notification Hubs, one with the sandbox APNs certificate for use with Xcode development builds, and one with the production APNs certificate for release and ad-hoc builds. If you don't have a separate instance of your MVC service for development, you will have to keep the device registrations straight somehow between the two.

Use a Service-Based database in visual studio with a mobile app

I'm pretty new in developing pc and mobile applications that need to work with the same database.
Maybe this isn't really a question but I would be happy to get some advice from you.
I have now a vs project written in C# with a Service-Based Database. I want to create a mobile app (can be only for android) and I want both the apps to use the same database.
What options do I have? Windows Azure isn't free and I can't spend any money on this so even a small trial (limitless) will work here.
I was thinking using Parse..
What do you recommend?
If I understand correctly I would suggest you create some backend service - web service or web api - that both application use which in turn uses the database.
This will allow you to re-use business logic across both applications, abstract the database away so that you can make database and logic changes without having to redeploy the applications and avoid the requirement to deploy database credentials with your applications (the backend service should employ some form of authentication)
A free-tier Azure mobile services can really help with the mobile device end but not necessarily on the PC (unless windows store app), but a free-tier Azure websites instance will happily host either web service or web api

Azure mobile services scheduled job - Are there alternatives to using javascript?

Background -
I am working on a Windows Phone RSS reader app (using C#). In addition to just reading RSS content, the app does some scraping on the articles linked by the feeds to get additional info. This is turning out to be too resource/bandwidth intensive to be done on the client and I am thinking of moving the RSS aggregation and scraping logic to the cloud.
I want to use Azure mobile services. In my simple design, I want to have-
(1) an Azure DB, which stores all the RSS data including the scraped content.
(2) Front end service which clients can call to get this data
(3) A scheduled task in the cloud that keeps the DB up to date with the latest RSS content. The processing here will be heavy weight since it will scrape thousands of webpages, process them to get additional information, and then update the DB.
* Actual question *
My question is regarding (3). I already have C# code that does this on the client and I want to be able to reuse it in developing the scheduled task in the service. I read the Azure mobile services documentation. What they seem to have is a scheduled job which runs javascript. I don't want to use java script and would prefer to reuse my C# code. What is a recommended (and non-hacky) way for me to do that?
You can use Windows Azure WebJobs:
http://www.windowsazure.com/en-us/documentation/articles/web-sites-create-web-jobs/
Just create a new (empty) website in Windows Azure, go to the "WEB JOBS" tab and add a new WebJob.
There you can upload your .NET console application which has all your logic (zipped), set a schedule according to your needs and you can use the web sites connection string setting (under the "CONFIGURE" tab) to set your connection string.
As of today, there isn't any option to run anything but javascript from your Mobile Service. HOWEVER, if you already have the C# code to perform #3, I would recommend wrapping that in a very light weight Web Service (Web API, etc). You can host this from Windows Azure Websites. You can then use the Windows Azure Scheduler to schedule a ping of that service which will kick off your job. You could use the Mobile Services scheduler to ping it as well but using the WA Scheduler would be even easier.

Categories