Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

AppleDevice is missing in Xamarin.Forms.Labs 1.2.1-pre2

$
0
0

I have an iOS + PCL solution and I need to get XForms.Labs Geolocator working in my PCL but right now all calls to Resolver.Resolve() return NULL. So I'm guessing that XLabs isn't getting initialized properly. The XLabs Wiki says that a container must be setup before using XLabs services.

To test this I created new solution (unified API) with Xamarin Studio and used NuGet to install XForms 1.3.1.6296 and XForms.Labs 1.2.1-pre2. Next I copied the container setup code from XLabs Wiki into my AppDelegate class however this will not compile because AppleDevice cannot be resolved.

How can I fix this?

Here is my AppDelegate.cs

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;
using Xamarin.Forms.Labs.Services;
using Xamarin.Forms.Labs;

namespace UnifiedTest.iOS
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init ();

            SetIoc ();

            LoadApplication (new App ());

            return base.FinishedLaunching (app, options);
        }

        private void SetIoc()
        {
            var container = new SimpleContainer ();
            container.Register<IDevice> (t => AppleDevice.CurrentDevice);
            container.Register<IDisplay> (t => t.Resolve<IDevice> ().Display);
            container.Register<INetwork>(t=> t.Resolve<IDevice>().Network);

            Resolver.SetResolver (container.GetResolver ());
        }
    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>