-->2.2 Add the
App Center Distribute will let your users install a new version of the app when you distribute it via App Center. With a new version of the app available, the SDK will present an update dialog to the users to either download or postpone the new version. Once they choose to update, the SDK will start to update your application.
May 20, 2015 An app in the Mac App Store is NOT allowed to install anything into the main OS X system or system kernel. This is one of the reasons you do not see antivirus software being sold in the Mac App Store other than something like ClamXAV which doesn't install anything into the main OS X system folder and hence, allowed to be sold and downloaded. You throw away a folder without checking its contents, or prematurely decide you won't need a certain file anymore. That's why you should consider using an application like Disk Drill; to protect you against yourself and the fancies of technology.
Warning
Google Play considers the in-app update code as malicious behavior even if it isn’t used at runtime. Use a variant of the Distribute SDK as directed in this section before submitting your app to Google Play. Failure to not remove the in-app update code can lead to noncompliance and removal of the app from Google Play.
Note
If you are running automated UI tests, enabled in-app updates will block your automated UI tests as they will try to authenticate against the App Center backend. We recommend to not enable App Center Distribute for your UI tests.
Add in-app updates to your app
Follow the Get started section if you haven't set up and started the SDK in your application, yet.
1. Add the App Center Distribute module
The App Center SDK is designed with a modular approach – a developer only needs to integrate the modules of the services that they're interested in.
Visual Studio for Mac
- Open Visual Studio for Mac.
- Click File > Open and choose your solution.
- In the solution navigator, right click the Packages section, and choose Add NuGet packages....
- Search for App Center, and install App Center Distribute.
- Click Add Packages.
Visual Studio for Windows
- Open Visual Studio for Windows.
- Click File > Open and choose your solution.
- In the solution navigator, right-click References and choose Manage NuGet Packages.
- Search for App Center, and install Microsoft.AppCenter.Distribute.
Package Manager Console
- Open the console in Visual Studio. To do this, choose Tools > NuGet Package Manager > Package Manager Console.
- If you're working in Visual Studio for Mac, make sure you have the NuGet Package Management Extensions installed. For this, choose Visual Studio > Extensions, search for NuGet and install, if necessary.
- Type the following command in the console:
Note
If you use the App Center SDK in a portable project (such as Xamarin.Forms), you must install the packages in each of the projects: the portable, Android, and iOS ones. To do that, you should open each sub-project and follow the corresponding steps described in Visual Studio for Mac or Visual Studio for Windows sections.
2. Start App Center Distribute
To use App Center, you must opt in to the module(s) that you want to use. By default no modules are started and you will have to explicitly call each of them when starting the SDK.
2.1 Add App Center Distribute imports
Add the App Center Distribute imports before you get started with using Distribute module:
- Xamarin.iOS - Open the project's
AppDelegate.cs
file and add the following lines below the existingusing
statements - Xamarin.Android - Open the project's
MainActivity.cs
file and add the following lines below the existingusing
statements - Xamarin.Forms - Open the project's
App.xaml.cs
file and add the following lines below the existingusing
statements
2.2 Add the Start()
method
Add
Distribute
to your Start()
method to start App Center Distribute service.Xamarin.iOS
Open the project's
AppDelegate.cs
file and add the Start()
call inside the FinishedLaunching()
methodXamarin.Android
Open the project's MainActivity.cs file and add the
Start()
method call inside the OnCreate()
method:To enable in-app updates for debug builds on Android, call the following method before
AppCenter.Start
:Xamarin.Forms
To create a Xamarin.Forms app targeting both Android and iOS platforms, you must create two apps in the App Center portal - one for each platform. Creating two apps will give you two App secrets - one for Android and another one for iOS. Open the project's
App.xaml.cs
(or your class that inherits from Xamarin.Forms.Application
) in the shared or portable project and add the Start()
call inside the OnStart()
override method.For your iOS application, open the
AppDelegate.cs
and add the following line before the call to LoadApplication
:This step is not necessary on Android where the debug configuration is detected automatically at runtime.
Throw Away App Mac Free
To enable in-app updates for debug builds on Android, call the following method in the project's MainActivity.cs file, in the
OnCreate
method and before LoadApplication
.Note
This method only affects debug builds, and has no impact on release builds.
2.3 [For iOS only] Modify the project's Info.plist
App Center SDK checks urls redirecting to the application to avoid sideloading, so in order for updates distributed through the portal to be handled correctly, you would need to specify
CFBundleURLSchemes
in CFBundleURLTypes
section of Info.plist
file:Note
Info.plist
, or an information property list file is a structured text file that contains essential configuration information for a bundled executable.You can find more information about it in Apple developer documentation.- Add a new key for
URL types
orCFBundleURLTypes
in your Info.plist file (in case Xcode displays your Info.plist as source code). - Change the key of the first child item to
URL Schemes
orCFBundleURLSchemes
. - Enter
appcenter-${APP_SECRET}
as the URL scheme and replace${APP_SECRET}
with the App Secret of your app.
Tip
If you want to verify that you modified the Info.plist correctly, open it as source code. It should contain the following entry with your App Secret instead of
${APP_SECRET}
:Remove in-app updates for Google Play builds
Google Play considers the in-app update code as malicious behavior even if it isn’t used at runtime. Failure to not remove the in-app update code can lead to noncompliance and removal of the app from Google Play. In order to make it easier, we provide the version of App Center Distribute SDK with stubbed APIs, so the only change for you is just a dependency swap.
- Add a new build configuration named
GooglePlay
for your Xamarin.Android project. Make sure that the project build configuration is correctly mapped to the appropriate solution configuration. See Visual Studio or Visual Studio for Mac instructions for more details. - Open Xamarin.Android project's
.csproj
in any text editor and move distribute reference into the conditional item group:NoteIf you are using old packages.config format to manage NuGet references, you can migrate to a PackageReference format, follow the migration instruction. - Save your changes and restore NuGet packages.
- You can change the configuration in the command bar at the top of the IDE.
Use private distribution group
By default, Distribute uses a public distribution group. If you want to use a private distribution group, you will need to explicitly set it via
UpdateTrack
property.Note
The default value is
UpdateTrack.Public
. This property can only be updated before the AppCenter.Start
method call. Changes to the update track are not persisted when the application process restarts, and so if the property is not always updated before the AppCenter.Start
call, it will be public, by default.After this call, a browser window will open up to authenticate the user. All the subsequent update checks will get the latest release on the private track. The update track is not persisted in the SDK across app launches.
If a user is on the private track, it means that after the successful authentication, they will get the latest release from any private distribution groups they are a member of.If a user is on the public track, it means that they will get the latest release from any public distribution group.
Disable Automatic Check for Update
By default, the SDK automatically checks for new releases:
- When the application starts.
- When the application goes into background then in foreground again.
- When enabling the Distribute module if previously disabled.
If you want to check for new releases manually, you can disable automatic check for update.To do this, call the following method before the SDK start:
Note
Throw Away App Mac Ios
This method must be called before the
AppCenter.Start
method call.Then you can use the
CheckForUpdate
API which is described in the following section.Manually Check for Update
Note
A manual check for update call works even when automatic updates are enabled. A manual check for update is ignored if another check is already being performed. The manual check for update will not be processed if the user has postponed updates (unless the latest version is a mandatory update).
Throw Away App Mac Desktop
Customize or localize the in-app update dialog
1. Customize or localize text
You can easily provide your own resource strings if you'd like to localize the text displayed in the update dialog. Look at the string files for iOS in this resource file and those for Android in this resource file. Use the same string name/key and specify the localized value to be reflected in the dialog in your own app resource files.
2. Customize the update dialog
You can customize the default update dialog's appearance by implementing the
ReleaseAvailable
callback. You need to register the callback before calling AppCenter.Start
as shown in the following example:Here is an example on Xamarin.Forms of the callback implementation that replaces the SDK dialog with a custom one:
Implementation notes for Xamarin.Android:
As shown in the example, you have to either call
Distribute.NotifyUpdateAction(UpdateAction.UPDATE);
or Distribute.NotifyUpdateAction(UpdateAction.POSTPONE);
if your callback returns true
.If you don't call
NotifyUpdateAction
, the callback will repeat on every activity change.The callback can be called again with the same release if the activity changes before the user action is notified to the SDK.
This behavior is needed to cover the following scenarios:
- Your application is sent to the background (like pressing HOME) then resumed in a different activity.
- Your activity is covered by another one without leaving the application (like clicking on some notifications).
- Other similar scenarios.
In that case, the activity hosting the dialog might be replaced without user interaction. So the SDK calls the listener again so that you can restore the custom dialog.
Enable or disable App Center Distribute at runtime
You can enable and disable App Center Distribute at runtime. If you disable it, the SDK will not provide any in-app update functionality but you can still use Distribute service in App Center portal.
To enable App Center Distribute again, use the same API but pass
true
as a parameter.You don't need to await this call to make other API calls (such as
IsEnabledAsync
) consistent.The state is persisted in the device's storage across application launches.
Note
This method must only be used after
Distribute
has been started.Check if App Center Distribute is enabled
You can also check if App Center Distribute is enabled or not:
Note
This method must only be used after
Distribute
has been started, it will always return false
before start.How do in-app updates work?
Note
For in-app updates to work, an app build should be downloaded from the link. It won't work if installed from an IDE or manually.
The in-app updates feature works as follows:
- This feature only works with RELEASE builds (by default) that are distributed using App Center Distribute service. It won't work if the iOS Guided Access feature is turned on.
- Once you integrate the SDK, build release version of your app and upload to App Center, users in that distribution group will be notified for the new release via an email.
- When each user opens the link in their email, the application will be installed on their device. It's important that they use the email link to install - we do not support side-loading. When an application is downloaded from the link, the SDK saves important information from cookies to check for updates later, otherwise the SDK doesn’t have that key information.
- If the application sets the track to private, a browser will open to authenticate the user and enable in-app updates. The browser will not open again as long as the authentication information remains valid even when switching back to the public track and back to private again later. If the browser authentication is successful, the user is redirected back to the application automatically. If the track is public (which is the default), the next step happens directly.
- On iOS 9 and 10, an instance of
SFSafariViewController
will open within the app to authenticate the user. It will close itself automatically after the authentication succeeded. - On iOS 11, the user experience is similar to iOS 10 but iOS 11 will ask the user for their permission to access login information. This is a system level dialog and it cannot be customized. If the user cancels the dialog, they can continue to use the version they are testing, but they won't get in-app-updates. They will be asked to access login information again when they launch the app the next time.
- On iOS 9 and 10, an instance of
- A new release of the app shows the in-app update dialog asking users to update your application if it has:
- iOS:
- a higher value of
CFBundleShortVersionString
or - an equal value of
CFBundleShortVersionString
but a higher value ofCFBundleVersion
. - the versions are the same but the build unique identifier is different.
- a higher value of
- Android:
- a higher value of
versionCode
or - an equal value of
versionCode
but a different value ofversionName
.
- a higher value of
Tip
If you upload the same apk/ipa a second time, the dialog will NOT appear as the binaries are identical. On iOS, if you upload a new build with the same version properties, it will show the update dialog. The reason for this is that it is a different binary. On Android, binaries are considered the same if both version properties are the same.
How do I test in-app updates?
You need to upload release builds (that use the Distribute module of the App Center SDK) to the App Center Portal to test in-app updates, increasing version numbers every time.
- Create your app in the App Center Portal if you haven't done that already.
- Create a new distribution group and name it so you can recognize that this is just meant for testing the in-app update feature.
- Add yourself (or all people who you want to include on your test of the in-app update feature). Use a new or throw-away email address for this, that was not used for that app on App Center. This ensures that you have an experience that's close to the experience of your real testers.
- Create a new build of your app that includes App Center Distribute and contains the setup logic as described below. If the group is private, don't forget to set the private in-app update track before start using the
UpdateTrack
property. - Click on the Distribute new release button in the portal and upload your build of the app.
- Once the upload has finished, click Next and select the Distribution group that you just created as the Destination of that app distribution.
- Review the Distribution and distribute the build to your in-app testing group.
- People in that group will receive an invite to be testers of the app. Once they accept the invite, they can download the app from the App Center Portal from their mobile device. Once they have in-app updates installed, you're ready to test in-app updates.
- Bump the version of your app (
CFBundleShortVersionString
orCFBundleVersion
for iOS,versionCode
for Android) - Build the release version of your app and upload a new build of your app just like you did in the previous step and distribute this to the Distribution Group you created earlier. Members of the Distribution Group will be prompted for a new version the next time the app starts.
Tip
Have a look at the information on how to utilize App Center Distribute for more detailed information about Distribution Groups etc.While it is possible to use App Center Distribute to distribute a new version of your app without adding any code, adding App Center Distribute to your app's code will result in a more seamless experience for your testers and users as they get the in-app update experience.
Disable automatic forwarding of application delegate's methods to App Center services
App Center uses swizzling to automatically forward your application delegate's methods to App Center services to improve SDK integration. There is a possibility of conflicts with other third party libraries or the application delegate itself. In this case, you might want to disable the App Center application delegate forwarding for all App Center services by following the steps below:
- Open the project's Info.plist file.
- Add
AppCenterAppDelegateForwarderEnabled
key and set the value to0
. This will disable application delegate forwarding for all App Center services. - Add
OpenUrl
callback in yourAppDelegate.cs
file.
JASPER, ALTA. — Perfectly good food in grocery stores and restaurants is going to waste, and Melody Gaboury wants to change that with a food recovery program in Jasper.
“I don’t like the idea of waste,” she said. “It makes me sad to think about any type of waste – food, clothing.”
Gaboury said she was worried about the future of the world for the next generation and decided to take action and make change locally.
“I’d like to (create) positive change, starting in our community, reducing waste,” she said.
Expiry dates, a few spots on fruits and vegetables, and items that aren’t used in a recipe all contribute to the huge amount of food thrown away regularly by businesses.
But Gaboury said with careful scrutiny much of the food that is thrown out is actually still safe to eat.
The mom-of-two, and owner of My Jasper Nanny, is continuing an effort started almost a year ago to get a program, Jasper Food Recovery, up and running.
She has reached out to local businesses with emails and through Facebook to make a connection for a supply of goods to be used by community members.
“We want to convey the message that food recovery is for everyone – anybody who wants to reduce waste,” she said. “Some people might think it’s not for them because they can afford food, but it’s about changing your perspective. Just because something has a bruise on it doesn’t mean it’s not good to eat.”
Jasper Food Recovery, she said, already has a location in place and volunteers to carry out their plan.
Volunteers will pick up food at contributing businesses and the group will accept low-risk donations like fruits, vegetables, canned food, dry, unopened packaged goods, and baked goods without perishable filling.
The donations will be taken to the Anglican Church Hall, where community members can pick up the free items set out on tables on Tuesdays from 11 a.m. to 12:30 p.m. and Thursdays from 3 p.m. to 5:30 p.m., using their own bags.
To facilitate COVID protocol, folks will enter in one door and exit through another, to keep the traffic going in one direction. There will also be a guest registry used for contact tracing.
“We’ll be relying on the fact that community members come and take what we have,” said Gaboury. “I hope everyone will participate – businesses and community members.”
Watch the Jasper Food Recovery Facebook page for updates about the start of the program or email [email protected] for more information.
View original article here Source