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.
Related
Background: We have developed a Windows Service in C# .NET 4.5. The service does two jobs at once.
It communicates with LDAP and reads the user statuses and updates in the Database.
It communicates with the Database and rolls out items to users.
Requirement: We have got the opportunity to rewrite the service in .NET Core. We need to write the service to achieve the following targets.
The old clients who are using their own infrastructure could install and use the service like they are doing now.
The clients who are using CLOUD should be able to install it on the cloud. But I don't think for a single service we are required to use VM. Is there a better way to handle this scenario?
The service's 1st part is communicating with LDAP. Clients who are using the cloud, definitely have the database hosted on the cloud along with the other Web Applications but where should be the service installed so it can easily communicate with the LDAP as well as with the database (2nd part)?
I heard about the background worker process. Does the windows service be used as a background worker process and as a windows service at the same time?
For .NET Core take a look at Microsoft.Extensions.Hosting.BackgroundService for windows services.
As far as the Cloud issue I assume it would depend on how the customer is setup. If LDAP is still on-prem, I assume it would be easier to have the service running on-prem as they would probably have a connection to the VPC on the Cloud where the database is hosted.
If everything exists on the Cloud then I assume it would the depend on the provider how you can run the service? Small EC2 instance on Amazon, on Azure you might have to use a VM or maybe look at a WebJob on an AppService, not very familiar with Google.
Hope this helps.
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 :-
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
I'm trying to develop a Android app which transfers mobile specific information like Text messages or Files from any Android mobile to a cloud. Can I know the process of data transmission from an Android device to a cloud. As a developer how can I proceed and integrate it with cloud.
I am assuming you are talking about using cloud database providers for your android application and not setup up or your own cloud database, you have to be specific what cloud database provider(s) that you are interesting in.
I suggest you to try Dropbox. Dropbox has a very easy to use set of APIs.
Drop-ins: you do not have to do anything (component base)
Sync Api: very easy to use and pretty much handle everything for you.
core API: more flexible, since it is designed for server, you have to write your own nano http server to handle oauth2 authentication's url redirection or your users have to copy "authorization codes" manually from browser.
I suggest you use Sync Api.
I am using sync API for my Android App (EPass PM) and use core API with nano http server to handle OAuth2 for desktop version.
Here is the link to Dropbox api
https://www.dropbox.com/developers
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.