Coder Social home page Coder Social logo

f50's Introduction

Xamarin.Services.Experimental

This is a prototype to help explore various existing plugins, their code, and API's in an effort to better understand how we could combine various bits of cross platform API's/functionality into one single repository and binary effort.

Much of this code is ported from existing plugins, and has not been refactored to the extent it will need to be.

There are a number of discussion points and ideas that remain to be resolved and implemented:

  • What platforms should be supported? Should we support some platforms in some functionality when we can, or should we only support a platform if all features can be reasonably well implemented on it?
  • We think that one assembly, one nuget package is ideal, but we need to discuss any outstanding issues with this approach:
    • We can't (easily) automatically and conditionally define permissions for features like Location on Android
    • What's the impact to developers if we take dependencies on other libraries (eg: Google Play Services - Location) which are only used by small parts of the overall library
    • How do we ensure the managed linker strips out everything that is irrelevant to the app consuming the library?
    • We need to ensure that compiled apps don't link against frameworks they aren't actually using (for example, on iOS, apps may be rejected for linking against Location services, but not specifying the appropriate permissions in the Info.plist)
    • Linking: Some plugin code currently uses [Preserve] to get around necessary classes being linked out, which we want to be more clever about since we want as much as possible to be linked out of the build
  • We should check to ensure developers have the appropriate permissions declared in their platform app configurations and throw a useful exception when they do not:
    • iOS apps sometimes need entries in the Info.plist describing the intent behind using the functionality
    • Android apps need permissions defined in the AndroidManifest.xml
  • There are already a few obvious API considerations, and will definitely be more as we design it:
    • Discuss the merits of a consistent IsAvailable and IsEnabled set of properties or methods on each service class
    • Premissions API needs restructuing - should it know about all of the permission types? Or should each set of API's with specific functionality know about these and deal with them behind the scenes. We may want a consistent API here with things like HasPermission() and RequestPermission() calls for any feature requiring permissions.

Geolocation

var geo = new GeolocationService {
    DesiredAccuracy = 50 // 50 meters
};

if (geo.IsSupported && geo.IsEnabled) {
    var pos = await geo.GetPositionAsync (TimeSpan.FromSeconds(60));
    Console.WriteLine($"{pos.Latitude}, {pos.Longitude} @ {pos.Timestamp}");
}

Text-to-Speech

var tts = new TextToSpeechService ();
await tts.SpeakAsync ("Hello, Monkey!");

Permissions

var ps = new PermissionsService ();

var status = await ps.CheckPermissionStatusAsync(Permission.Location);

if (status != PermissionStatus.Granted) {
    // See if we should request permissions
    if (await ps.ShouldShowRequestPermissionRationaleAsync (Permission.Location))
        // Request permissions
        var results = await ps.RequestPermissionsAsync (Permission.Location);
		// Check the request results
        if (results.ContainsKey (Permission.Location))
        	status = results[Permission.Location];
    }
}

if (status == PermissionStatus.Granted) {
    /* Do your thing! */
} else {
    Console.WriteLine ("Permission was denied :("));
}

f50's People

Contributors

mattleibow avatar redth avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

mattleibow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.