Sending Push Notification to Windows 8 Metro style app in C# - c#

I've downloaded the Microsoft sample code for registering your app to push notifications to. Sample
I have sent the channel URI to myself in an email, and I believe I have all the relevant information to actually send a push. But I've never dealt with the server-side sending of a push notification.
The sample app should just output whatever I send.
I can't find any pre-existing apps to help me. I just want to be able to see some information in the sample app window. From there I should be able to figure out what to send in future, headers, etc.
Is there a sample app, where I just put in the Channel Uri, token, SID and secret, and it'll send something like "Hello world" to my app? Preferably with source, so I can take it apart and see how it's being done.

Take a look at the tutorial for the Windows Azure Mobile Services Push Notification:
http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-push-dotnet/

I will second the recommendation for Windows Azure Push Notifications, with another blog overview (using JavaScript) here
If you do want to get under the hood a bit more the reference pointed to above - http://watwindows8.codeplex.com/ - does work with RTM; however, the setup is coded to work only with the Release Preview.
If you'd like to set it up you can do the following:
In Setup\CheckW8.ps1 change the build number in text from 8400 to 9200
$os = Get-WmiObject Win32_OperatingSystem;
if ($os.BuildNumber.Equals("9200")) {
exit 1;
}
...
Then in Setup\DependencyChecker\WATWindows8.depi, delete the three <dependency> sections entirely. The assumption here is that you already have Visual Studio 2012 RTM, the Azure Tools for 2012 RTM, and NuGet is up to date.
When you run the setup as instructed by the Toolkit, it should now work. You'll get an empty list of dependencies, but that's fine since you've already installed them manually.
The C# Push Notification sample code should be fine on a recompile (you'll get an error about the package name, but that's expected since it's part of the configuration you need to do).
For the JavaScript version, you'll have to patch the script references to the RC version in default.html, remove the old "Window Library for JavaScript" from the references and add the new one.

Related

Interacting with an open application via web link [duplicate]

A few years back I developed a Silverlight Component called from within an ASP.net web app, that uses PInvoke to access a USB (Serial COM port) on the client machine to allow for sending commands to some scanner hardware.
With the advent of Windows 10 and the inevitable demise of Silverlight I am looking for alternatives to accessing hardware on the client PC (This is all Intranet Web Application stuff where we have a lot of control over the implementation)
Currently I am looking at Registering an Application to a URI Scheme (Easy solution) as per this page:https://msdn.microsoft.com/library/aa767914(v=vs.85).aspx
OR alternatively maybe Javascript navigator.msLaunchUri (This seems to not be supported in Windows 7, which we need to still support)
Refer: https://connect.microsoft.com/IE/feedback/details/864863/documented-api-function-navigator-mslaunchuri-not-present-in-windows-7
The Registering of an Application to a URI Scheme works fine in Windows 7/8/8.1 but seems to have changed in Windows 10 - Does anyone know how I can implement this (Through C# code, registry, something) to allow this to work in Windows 10
I recently wanted to just this as well - and I found the answer so i'm posting it here for future reference and I couldn't find a working example in C# anywhere.
First of all your app needs requireAdministrator permissions. To do this, right click on the project in the Solution Explorer and click Add New Item, then select General and finally Application Manifest file if you don't already have one. In there, change the requestedExecutionLevel to requireAdministrator. Save.
I this is the first time you've done this, you'll need to restart Visual Studio as it probably isnt running under Admin privaleges.
Okay, so I wanted my app to create the registry key when it starts up, so in the constructor for my form I put in the following code, which creates the URL Protocol foo:// for a program called 'oggsplit.exe' (which I happened to have in my C: root so I just used that for testing)
RegistryKey key;
key = Registry.ClassesRoot.CreateSubKey("foo");
key.SetValue("", "URL: Foo Protocol");
key.SetValue("URL Protocol","");
key = key.CreateSubKey("shell");
key = key.CreateSubKey("open");
key = key.CreateSubKey("command");
key.SetValue("", "C:\\oggsplit.exe");
Once you've configured that, save and run the program. You'll get no feedback, and as long as you don't see any errors it should have worked correctly. Now, open your browser (no need to restart or anything) and go to the address foo://hello. This is what it looks like for me in Google Chrome:
It will then ask you if you want to open your application from the browser, click okay. Hey Presto, your app opens from the browser, you can now put a specilised link into your web page to open your app from the browser. This Page also documents how to pass arguments through to your program as well.
In win10 you can try to use URI handlers. There should be Package.appxmanifest file where you can list URIs that should launch your app.
Also, I found interesting the folowing article that describe web-to-app approach for various OS

Evernote notes overwritten when updated externally

I'm building an app that updates Evernote notes via the Windows C# API. I've noticed an issue where a note that is updated by my app in between sync's in the Windows desktop app (for example) is overwritten.
This also happens when a note is updated in between sync's via another app (e.g. iPhone). To explain this further I've outlined the steps to reproduce the problem using the Windows and iPhone apps.
Please note that in order to repro this there must be a delay in between syncs in the Windows app. Within the app the sync interval can be changed in Tools > Options > Synchronization:
Create note with a reminder in the Windows app
Manually sync Evernote (Windows app)
Sync this note to another device, say the iPhone app
Add a tag to the note & sync (iPhone app)
Complete the reminder in the Windows app
Manually sync Evernote (Windows app)
If the above steps "work", once the Windows app is sync'd the reminder will be active (i.e. not complete) and the tag will be added.
I understand that this sort of scenario is unlikely to happen in a real usage scenario of Evernote, however as I am updating notes regularly via the API the chances of it happening or much more likely.
The ideal solution would be to update specific fields instead of the whole note, however I could see any way to do this.
Anyone have any ideas?
Thanks
When you call NoteStore#updateNote, try to set guid and only attributes you want to update and leave the rest unset.

Azure Mobile App Workflow

After using Azure Mobile Services a year ago, I decided to get back to mobile development but Microsoft changed a lot in their offer and I'm actually struggling to set my project up.
My goal is to create a service whith these features:
.NET backend preferred over the Javascript one (I don't like callbacks :))
SSO (Facebook, Twitter, Google+, Windows Live)
SQL Database (I really need relations, and I already have a T-SQL schema)
Push Notifications (just to Windows and Android for now and with unlimited custom channels so that I can have one channel for each user and avoid dealing with notifications' logic)
Monthly scheduled jobs to update database from an external JSON API and to remove old entries
Mobile Client (with a shared Xamarin library to handle all the data-related stuff and WUP + Android support)
Web Client (I don't have a Mac so I can't build and publish the iOS version, so a web app may be needed as a temporary replacement)
What I did was to:
Open Azure Preview Portal link
Click on New => Web + Mobile => Mobile App
Set the Resource Group with all the needed plans
Added a Data Connection to a newly created SQL Database
Added a Notification Hub with settings for GCM and WNS
Added Mobile Authentication with settings for Microsoft Account, Facebook, Twitter, Google
Created the schema for my SQL Database
Before going on, I'm not sure that this was the correct workflow but documentation is pretty confused and the Get Started sections just discuss about code and not how to properly setup the service and have it running, so I just did the same basic things that I would've done with the old Mobile Service, plus dealing with the SQL Database instead of the NOSQL one.
Now it comes the issue: I have no idea on how to move next, and even the Quickstart projects (both server and client) are not helpful (they're the old TodoItem sample working with the Mobile Service).
The first thing that I wanted to do was to create the Scheduled Job because I actually need to fill the database with the external data before moving forward.
The only thing close to what I need is the WebJob, but I can't schedule it yet and it requires me to upload an exe file while I'd like to be able to write my C# code directly to the server (being able to remotely debug it).
An alternative may be to create a Compute Instace and write an endless loop doing what I need, but this will force me to manually deal with the SQL Database inside the Mobile App Service.
Another issue is related to the SQL Database. As I already wrote, the Quickstart seems to work with the NOSQL included in the old Mobile Service, meaning that I don't have a direct connection to my SQL Database, while I'd like to be able something like
App.MobileService.GetTable<MyTable>()
Plus, having 10 tables, I'd also like to have a way to map them automatically (like NetBeans does for JavaEE projects).
So the question is: what's a good (or the best) workflow to get everything working as I need it or, at least, close to how I need it?
(I know that answers may be opionion-based but they still may be useful since Microsoft's documentation is not complete)
If you have an existing database, you could use Entity Framework Code First to Existing Database. That will generate the C# classes for you.
The database that you create when you add a Data Connection to your Mobile App is an Azure SQL Database by default--I'm not sure why you thought it was NoSQL?
Once you have done this, you can query your tables from the Azure Mobile Apps client SDK. For instance, in Xamarin, the quickstart project does queries as follows (see https://github.com/Azure/azure-mobile-services-quickstarts/blob/MobileApp/client/xamarin.android/ZUMOAPPNAME/ToDoActivity.cs#L126).
var list = await toDoTable.Where (item => item.Complete == false).ToListAsync ();
Finally, regarding your question on WebJobs, you can actually schedule it. See https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/#CreateScheduledCRON for more information. Even though you Web Deploy your webjob target, you can still remote debug it. See this blog post for information: http://www.bursteg.com/remote-debugging-azure-webjobs-attach-a-debugger-from-server-explorer/

Xamarin Android App update

I've been developing android apps on Xamarin for 3months now, but I am facing a problem to update the application when a new release is available.
The application is not published to any app store(as we use it internally), I know Play store can do automatic updating, but I need to look for an update on our server, I would prefer if all this can be done silently(in the background).
here is my current code, this copy's the app to the device:
intent.SetData(Android.Net.Uri.Parse(#"http://xxxxx/downloads/app.test-signed.apk"));
StartActivity(intent);
this installs the app onto the device:
intent.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.Path +
"/app.test-signed.apk")), "application/vnd.android.package-archive");
StartActivity(intent);
but this way it asks to install (and I don't think this is the correct way), and doesn't start my app automatically after it was installed. And I am not sure how to wait until the app finished downloading before it tries to install.
I had a similar issue with an app which only gets used internally in my company. I didn't want the app going to the big wide world as the general public wouldn't have any use for it.
So, what we've done is publish the final product as 'Alpha release' in Google Play. You set up a Google Group with a set of e-mail addresses of devices that can access it, and once the app has been downloaded it will update just like any other app from Google Play.
There's an option to 'Promote' it to Beta or Production, but given that it never gets promoted it is never searchable on Google Play.
As Corey Ogburn mentionned, the silent install won't be possible without root.
Altough an answer was already posted to your question on Xamarin's forum.
On another note, following Dave's idea, you could set a Private Channel on Google Play. As you already know, Google Play offers easy automatic update, and with a Private Channel, you will be able to give special authorization on who has access to your app.
Read more on Private Channel here.

Windows Embedded HTTP Server with Bonjour(Zeroconf) Support

I need to find or create an HTTP server that will run on a Windows machine and announce its presence via Bonjour(Zeroconf). I've searched all over the web and can't seem to find anything that fits the bill or even any information about how I would go about adding the Bonjour functionality to a server that I create.
I found that apache has mod_zeroconf, but it only runs under Linux and found that Apple provides a Bonjour installer for Windows, but it doesn't appear to add the announce functionality. I feel like I may be searching in the wrong places.
For my current project I'm ok with using something off-the-shelf, building with C#/.Net, or even rolling a rails/rack based server and setting up the announcement as a separate process.
I suspect you'll need to integrate Mono.Zeroconf.

Categories

Resources