GithubHelp home page GithubHelp logo

angelinn / xam.plugin.autoupdate Goto Github PK

View Code? Open in Web Editor NEW
35.0 6.0 7.0 2.33 MB

Xamarin Forms plugin that auto updates your Android or UWP sideloaded application.

License: MIT License

C# 95.88% Batchfile 4.12%
xamarin forms uwp android update auto-update plugin apk appx

xam.plugin.autoupdate's Introduction

Xam.Plugin.AutoUpdate

This library is not longer supported. If you need some functionality, PRs are accepted.

Auto update for your Android/UWP

android android uwp uwp

What is it?

  • Check for update and auto install sideloaded Android or UWP application
  • Check for update and redirect to play store
  • The auto install part works only with UWP and Android

How does it work?

  • Developer provides a check for updates function, returning if there is an update available and the url to the file, if provided
  • The plugin checks for updates every RunEvery period of time
  • When a new version is available and the user clicks the confirm button, the file from the provided url is downloaded and started

Installation

Nuget package will be available soon.

Install the package on the mobile projects in your solution (.netstandard, Android, UWP, iOS).

Android

For Android API > 23 a FileProvider configuration is required:

  • Add to AndroidManifest
  <application android:label="...">
    <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.companyname.application" android:grantUriPermissions="true" android:exported="false">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
    </provider>
  </application>
  • Create a new file - Resources/xml/file_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths>
  <files-path name="files" path="/" />
</paths>
  • Add to MainActivity
AutoUpdate.Init(this, authority);

NOTE: The authority value is the same as the android:authorities in the AndroidManifest file.

NOTE: Since Android Oreo (API 27), every app needs additional access to install APKs. You must add this permission if you wish to support Oreo:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

Usage

  • Create an UpdateManagerParameters option.
  • Use UpdateManager.Initialize(parameters, mode) somewhere in your forms project. (e.g in App.xaml.cs)
UpdateManagerParameters parameters = new UpdateManagerParameters
{
    Title = "Update available",
    Message = "A new version is available. Please update!",
    Confirm = "Update",
    Cancel = "Cancel",
    // choose how often to check when opening the app to avoid spamming the user every time
    RunEvery = TimeSpan.FromDays(1),
    CheckForUpdatesFunction = async () =>
    {
        // check for updates from external url ...
        return new UpdatesCheckResponse(true, downloadUrl);
    }
}

Use UpdateMode.AutoInstall to download and install the application

UpdateManager.Initialize(parameters, UpdateMode.AutoInstall);

or UpdateMode.OpenAppStore to open the corresponding app store

UpdateManager.Initialize(parameters, UpdateMode.OpenAppStore);

Auto install

Using the auto install mode, the plugin will download the file provided in the DownloadUrl parameter and launch it as apk or appxbundle, depending on the platform.

Note: As stated earlier, this option does not work with iOS, due to the restrictions of the operating system.

Open app store

Using the open app store mode, the plugin will open the specified platform's app store, if an update is available.

Note: Additional logic is used for android to determine that only the Google Play store can open the market:// url and no other app that has registered for it.

xam.plugin.autoupdate's People

Contributors

angelinn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

xam.plugin.autoupdate's Issues

nuget package ?

Hello,

Your plugin is excellent, pretty clean ! Good work. :)
Do you have a date for the nuget package? Or is it better to extract the sources for now ?

Will it be available on NuGet?

Sir. When it will be available on NuGet Package Manager? So that it will be helpful for most of the people like me for android app development.

Looking for a NuGet package

Hello there, I can see that your last commit was almost 3y ago and I'm wondering if there is an update.

I would really like to use your package via NuGet. It would be very helpful.

Thanks.

How about android 7.0 or later?

Can it work well on android 7.0 or later ,such as 7.1 or 8.x ?
I have a Android project written by C# , Can I use your code?

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.