MonoGame - References to Microsoft.Phone assemblies - windows-phone-7

How to cope with the Microsoft Phone specific assemblies when loading the classes inside a MonoGame For Android project (MonoGame FrameWork)? As e.g:
using Microsoft.Phone.BackgroundAudio;
using Microsoft.Phone.Marketplace;
using Microsoft.Phone.Tasks;
using System.Device.Location;

These will have to #if defed out as they are not currently supported under MonoGame.
Background audio should be supported via the Song and Sound classes though.
I think the MarketPlace namespace is an interesting one, and is one that should not be phone specific, as MacOS also has an App Store.
I hope this helps.

Related

TokBox OpenTok SDK for Xamarin Forms

I have made proof of concept app for a video chat application in Xamarin Native using the below nuget packages (it works like a charm the source code is done by provider available here https://github.com/DreamTeamMobile/Xamarin.Opentok.Samples/tree/code-improvements)
https://www.nuget.org/packages/Xamarin.OpenTok.Android/
https://www.nuget.org/packages/Xamarin.OpenTok.iOS/
These nuget packages are basically a port of the native iOS/Android SDK's by TokBox for Xamarin, Created by DreamTeamMobile. I want to make use of them to for creating a Xamarin Forms application, I need some guidance how I can make the same functionality available to a Forms Project, considering that the package provider doesn't provides Xamarin Forms implementation. Would custom renderers help here.
In my case using Xamarin Forms (Shared Project), I used native views ref to made Room page and I used the given services to streaming from the Sample code ref, basically was copy and paste the services. Each service and whatever I needed from Android or iOS was included with Conditional compiler ref.
I hope it's useful.

Mono.data.sqlite on Universal WIndows Platform

I'm having trouble getting my shared project to work with my UWP application. The shared project uses Mono.Data.Sqlite for the database connection and it works on Android and iOS, but I don't know what reference I'm missing since it doesn't recognize the library on UWP. Anyone tried this before?
On Windows Phone the SQLite engine does not come by default so you need to add support for it. This is an easy step. Just add the precompiled binaries. A way how you can do this can be read here.
This is why the Mono.Data.Sqlite namespace will not work on UWP applications. To work around this issue you have to use compiler switches. For example:
#if !WINDOWS_PHONE
using Mono.Data.Sqlite;
#endif
#if WINDOWS_PHONE
using Whatever namespace it is.
#endif
This will work with SharedProjects. An other option would be a PCL (Portable Class Library) that contains your shared code. With this you can use the SQLite-NET – Cross-Platform ORM.

Porting WP App to Android with Cordova - pick folder

I have found a nice topic about porting WinJS Apps to Android ( and now can use WinJS ), but have not found any else information.
For example I want to use Windows.Storage.Pickers.FolderPicker(). As I have understand namespace Windows is missing. What should I use instead of?
Have no idea - could someone who knows Cordova well help? I'll write an article if I'll understand it)
The Windows namespace is not a part of WinJS but a part of WinRT. So you cannot use it on android cordova project.
We have developed an abstraction layer to provide the same functions to access to multiple operations like reading / writing files / access to photo library, recording sounds regardless on WinRT or Cordova context. (namespace : winjscontrib.datacontainer)
You can find in this project (https://github.com/gleborgne/winjscontrib)
Other explanations are here (but written in french :))
http://mcnextpost.com/2015/02/16/ecriturelecturemodification-de-fichiers-dans-un-projet-universel-app-et-cordova/
http://mcnextpost.com/2015/02/16/winjs-dans-une-application-cross-plateforme-cordova/

Decryption in PCL project in xamarin application

I am developing an application using xamarin.android, xamarin.ios and windows phone 8.1 silver light. I am using an encrypted data and want to decrypt data in PCL project. For encryption AesCryptoServiceProvider class has been used. I want to decrypt my data in PCL project but not found any library for doing this. The above mentioned class is worked well in Android and ios project but I am not be able to use in windows phone project. Any help regarding this is much appreciated.
Thanks in advance
Dependency injection/IoC is your friend. Basically you would implement an interface in PCL and implement it at OS level with whatever type is there that does the job.
Have a look at PCL Crypto. It probably supports the functionality you need.

Xamarin & Visual Studio, Windows Phone & ASP.NET: Is a true single class library possible?

I've currently built a service layer and API which I'm consuming from an ASP.NET website, Windows Phone app, and a Windows 8 metro app - the key to all of them being a project containing model classes which is a portable class library project, and is shared as a reference between all of them. This architecture works fine and without any issues.
However, I've recently started experimenting with Xamarin - specifically the iOS functionality (with a view to moving onto Android later). My initial assumption was that I would be able to utilise this model library as I do with the other projects - however, I've since realised this this isn't the case.
When I first added a reference to my model class library to my Xamarin.iOS project (in Visual Studio), I was greeted by the error:
'The current project does not support references to Portable Library projects'.
Strange - as I thought this would be a scenario that would be supported. I found a post here which suggested a fix that forced Visual Studio to detec the Monotouch (Xamarin) framework as supporting Portable Library Projects. Seemed to be exactly what I needed - but no. When I added the reference again, I was greeted by a different error:
'The current project's target framework is not compatible with that of the Portable Library project'.
And it suggests I change the target framework in the project properties. Except I can't, as the Xamarin iOS project needs to support Monotouch (and I can't change it to anything else from the GUI anyway). So I tried to change the model library's properties instead - maybe I can do something there. And it looked like I could. I can check Monotouch (Xamarin) as a supported platform here (where Windows phone, Windows store, etc are already checked), but it won't let me save. It just shows the message:
'There is no additional functionality that is supported by the target frameworks you have selected'
After some research, I discovered that the only way Xamarin suggest to share code is to use separate projects with linked code files (so in effect, a pseudo-single code base. Which I have tried and works - but it seems a hack. See here:
http://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options
So is this the only option? Or is there any way to have a true single class (model) library across all platforms, including Microsoft and Xamarin?
It is currently possible to use Portable Library Projects - e.g. profile 104 - across all of .Net4.5, WP, WinRT, Xamarin.Android and Xamarin.iOS
It is also currently possible to use the output binary assemblies across .Net4.5, WP, WinRT and Xamarin.Android - but not current against Xamarin.iOS.
This situation is changing 'very soon' now with Xamarin adopting full PCL support - see http://slodge.blogspot.co.uk/2013/02/the-future-is-portable.html and listen to http://hanselminutes.com/362/ios-and-android-apps-with-xamarin-studio-20-and-miguel-de-icaza
I personally deliver MvvmCross (and a lot of apps that use MvvmCross) using PCLs - and have done for the last 6 months - but there is some setup pain involved in this currently. For some info see my blog:
http://slodge.blogspot.co.uk/2012/12/cross-platform-winrt-monodroid.html
http://slodge.blogspot.co.uk/2013/03/xamarinios-with-mvvmcross-in-vs2012.html
I do hope to provide an update on this in the very near future - it should work 'out of the box' soon.
The future is bright on Xamarin side, as it is going to support .NET 4.5 profile on all its platforms,
http://blog.xamarin.com/brave-new-async-mobile-world/
The only problem as far as I can see comes from Microsoft side, who refuses to unify its own platforms to a common profile (Windows 8 and Windows Phone 8 are still messy tailored versions no better than CF or Silverlight in my own situation).
Portable class libraries are out there, but as a library author (#SNMP) I rather build separate project files for my own projects as Xamarin suggests.

Resources