appcenter-sdk-react-native icon indicating copy to clipboard operation
appcenter-sdk-react-native copied to clipboard

AppCenter Distribute

Open joonmanji opened this issue 7 years ago • 22 comments

Hey y'all,

It seems like currently, there is no way to notify a user to download a new ipa or apk file when appCenter has been updated similar to what we see in MSDistribute and DistributeListener interfaces found here:

  • https://docs.microsoft.com/en-us/appcenter/sdk/distribute/ios
  • https://docs.microsoft.com/en-us/appcenter/sdk/distribute/android

Is this a planned feature?

joonmanji avatar Jan 18 '18 21:01 joonmanji

@frankenthumbs We don't support In-app updates in RN SDK at the moment. We'll add it to our backlog but there is no ETA.

In the meantime, you can use CodePush service to update your application directly on users devices. You can find more information here - https://docs.microsoft.com/en-us/appcenter/distribution/codepush/

elamalani avatar Jan 18 '18 22:01 elamalani

Any updates ? Curious if this is on the roadmap.

justinmahood avatar May 03 '18 00:05 justinmahood

@justinmahood This is not in our mid-term roadmap. We suggest using our Distribute CodePush service for updates in your RN app.

elamalani avatar May 03 '18 16:05 elamalani

This doesn't help for native code updates backing RN apps, and really hinders quick adoption of internal builds. :( Have been so excited using the rest of the appcenter stuff, very disappointed to not have in app updates here. Maybe better to switch back to hockeyapp until the SDK supports it.

deregtd avatar Sep 12 '18 18:09 deregtd

I went through some of the basic AppCenter Distribute install instructions here for iOS, and adapted others: https://docs.microsoft.com/en-us/appcenter/sdk/distribute/ios

  • I added the pod
  • Added the plist entry (don't know if that's still needed or not, haven't tried without yet)
  • In my AppDelegate.m, added:
#import <AppCenter/AppCenter.h>
#import <AppCenterDistribute/AppCenterDistribute.h>
...
// Boilerplate from the RN install:
  [AppCenterReactNativeCrashes registerWithAutomaticProcessing];  // Initialize AppCenter crashes

  [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];  // Initialize AppCenter analytics

  [AppCenterReactNative register];  // Initialize AppCenter 

// Added this
  [MSAppCenter startService:[MSDistribute class]];

I then went ahead and compiled it and pushed to a branch of my VSTS repo, then queued a build to push to app center (with sequential version numbers). Installed and ran it and it had me login as normal and closed the webview. Then queued a second build fo the same code, had it push to app center, then foregrounded the app on iOS and it popped up the automatic update prompt dialog!

deregtd avatar Sep 12 '18 23:09 deregtd

@deregtd glad it worked for you that way. I would add to make sure the version of distribute module matches the version of AppCenter/Core to avoid undefined behaviors (check that after every update of the npms).

Also for Android, adding

dependencies {
   def appCenterSdkVersion = 'sameVersionAsAppCenter Java, Not ReactNative'
   implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
}

The right version should be extracted from the appcenter build.gradle file and from the compile 'com.microsoft.appcenter:appcenter:version' line that does not have react-native in the package name.

And in MainApplication.java in onCreate:

AppCenterReactNativeShared.configureAppCenter(this);
AppCenter.start(Distribute.class);

Should work too.

guperrot avatar Sep 13 '18 00:09 guperrot

Hey everybody,

I am also very much interested in this feature. We have changes to our native code quite frequently, so using only CodePush is not enough. At the moment we are still using HockeyApp, but we are considering switching to App Center soon. Not being able to distribute builds could be a major blocker for this.

I know that as @deregtd and @guperrot described, we can work around this by simply using the native ios and android sdks. But I would still much prefer a solution which is integrated into the react-native sdk. It just looks much cleaner.

Any update on if this is being worked on / on the roadmap?

johannesloher avatar Dec 11 '18 00:12 johannesloher

@johannesloher Unfortunately, it's currently not on our roadmap to support in-app updates in React Native SDK. The solution is to either use CodePush or the feature directly from native iOS or Android SDK. We will keep this thread posted once we decide to support it in the SDK.

elamalani avatar Dec 11 '18 17:12 elamalani

That's unfortunate, but thanks for your quick reply. I believe we can live with the workaround.

johannesloher avatar Dec 11 '18 17:12 johannesloher

   def appCenterSdkVersion = 'sameVersionAsAppCenter Java, Not ReactNative'
   implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"

Hello. I am trying to setup this in my android app but have issues. I added in gradle def appCenterSdkVersion = '1.11.2' implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}" and in MainApplication java added AppCenter.start(Distribute.class); It build app but no updates I can not see . Can you please help?

Jalson1982 avatar Feb 08 '19 13:02 Jalson1982

Hi @Jalson1982, can you share VERBOSE logs with me?

annakocheshkova avatar Feb 11 '19 08:02 annakocheshkova

@Jalson1982 you also need the lines (as @guperrot mentioned, but without the extra import)

import com.microsoft.appcenter.reactnative.shared.AppCenterReactNativeShared;
...
   AppCenterReactNativeShared.configureAppCenter(this);

jordanwise avatar Jun 09 '19 14:06 jordanwise

Hello, am wondering if you're still not considering this on your roadmap. Thanks :)

fabiendem avatar Sep 11 '19 15:09 fabiendem

I made an attempt at writing a wrapper for AppCenter Distribute. Focusing on Android for now. I got something working, but in my scenario, I want to initialize AppCenter Distribute from the React/JS layer.

Problem is that the AppCenter Android SDK 2.3.0 relies on the onStart() and onResume() lifecycle of the main Activity to trigger the check for an update, there is no method to check manually.

By the time we want to initialize AppCenter from the React layer, onStart() has already been called. The only way to trigger the check for an update was to send the app to the background and then back to the foreground to trigger the onResume callback. This is fairly suboptimal in terms of UX. Calling via the bridge Distribute.getInstance() .onActivityResumed(this.reactContext.getCurrentActivity()); can work, but it's frankly a big dirty.

fabiendem avatar Oct 11 '19 17:10 fabiendem

To be supported officially it would need to be a native module just like we did for Analytics where we also rely on onResume. By initializing code from the native module the same way as Analytics the event will not be missed.

Now in the meantime the simplest way is to probably to modify MainApplication.java and do add

AppCenterReactNativeShared.configureAppCenter(application);
AppCenter.start(Distribute.class);

Before SoLoader.init(this, /* native exopackage */ false);.

The onResume event will not be missed by the module that way.

guperrot avatar Oct 11 '19 18:10 guperrot

Thanks for the reply 👍

Yeah to get something working instead I have used directly the AppCenter Android SDK, rather than the ReactNative SDK.

Problem with the snippet above and the onResume is that we cannot control the AppCenter.start(Distribute.class); call from the React/Js level.
By this I mean start it when we want once the React layer is ready and from the React layer, say in your <App /> component. But maybe that's not a great idea 🤷‍♂

fabiendem avatar Oct 11 '19 18:10 fabiendem

Even when using the Java Android SDK in java/kotlin apps there is no manual check, it's done when the app resumes. So that means there is no API to bind from Javascript just yet, it's only about setting up and lifecycle in the native code.

If you want to control whether the SDK is enabled or not, that's a different story. You could do the same thing as we do for Analytics where we can configure it to be disabled by default and expose Javascript method to wrap the setEnabled call. If that's the use case you can write a native module equivalent to Analytics.

guperrot avatar Oct 11 '19 20:10 guperrot

Thanks.

In the above, I am more interested in initializing AppCenter Distribute from the JS layer and the manual check scenario (not relying on the Activity lifecycle). Not really whether the SDK is enabled or not.

In the unofficial HockeyApp react-native wrapper it's corresponding to those methods: https://github.com/martincik/react-native-hockeyapp/blob/1d37936588a654c10ca8d8e7d67c5c52cdb5a3c0/index.js#L28-L31 https://github.com/martincik/react-native-hockeyapp/blob/1d37936588a654c10ca8d8e7d67c5c52cdb5a3c0/index.js#L36-L39

But meanwhile, I can totally work with the AppCenter Android native SDK. I will keep an eye on this repo 👍

fabiendem avatar Oct 12 '19 11:10 fabiendem

Any news on this? Is it still not supported for React Native?

robertontiu avatar Feb 18 '21 08:02 robertontiu

We didn't really need any AppCenter specific features, so we simply switched to Applivery which seems to work quite well with React Native.

johanarnor avatar Feb 18 '21 09:02 johanarnor

Hi guys,

Please kindly note that our team is focused on improving reliability and performance for App Center to around mid-2021. Because of this, we won't be making much progress around most feature requests. Read more here.

DmitriyKirakosyan avatar Feb 18 '21 23:02 DmitriyKirakosyan

Has anyone had any success with @deregtd's approach with Private groups at all? I've tried to set the updateTrack before starting the service, but the auth page it mentions in the docs doesn't appear, my hunch is that the native auth view in the Distribute SDK isn't playing nicely with the React Bridge, where as Public dist track just uses the system alert dialog.

  [AppCenterReactNative register];
  [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];
  [AppCenterReactNativeCrashes registerWithAutomaticProcessing];

  MSACDistribute.updateTrack = MSACUpdateTrackPrivate;
  [MSACAppCenter startService:[MSACDistribute class]];

I tried setting the delegate to self within AppDelegate.m after adding the MSACDistributeDelegate protocol in the header file. Still no luck though

#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <AppCenterDistribute/AppCenterDistribute.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, MSACDistributeDelegate>

@property (nonatomic, strong) UIWindow *window;

@end
  [MSACDistribute setDelegate:self];
  MSACDistribute.updateTrack = MSACUpdateTrackPrivate;
  [MSACAppCenter startService:[MSACDistribute class]];

tutts avatar Mar 18 '21 08:03 tutts

As we do not have plans to add support for this feature in the next year, I'm closing the issue.

DmitriyKirakosyan avatar Apr 15 '24 04:04 DmitriyKirakosyan