Jeremy Durham před 6 roky
rodič
revize
f73e165c99

+ 1 - 0
FirebaseAppDistribution.podspec

@@ -25,6 +25,7 @@ iOS SDK for App Distribution for Firebase.
   s.public_header_files = 'FirebaseAppDistribution/Sources/Public/*.h'
 
   s.dependency 'FirebaseCore', '~> 6.0'
+  s.dependency 'AppAuth'
 
   s.pod_target_xcconfig = {
     'GCC_C_LANGUAGE_STANDARD' => 'c99',

+ 3 - 0
FirebaseAppDistribution/Sources/FIRAppDistribution.m

@@ -87,4 +87,7 @@
   return (FIRAppDistribution *)instance;
 }
 
+- (void)checkForUpdateWithCompletion:(FIRAppDistributionUpdateCheckCompletion)completion {
+    completion(nil, nil);
+}
 @end

+ 52 - 4
FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h

@@ -17,8 +17,42 @@
 NS_ASSUME_NONNULL_BEGIN
 
 /**
- * The Firebase App Distribution API provides methods to annotate and manage
- * fatal and non-fatal reports captured and reported to Firebase App Distribution.
+* The release information returned by the update check when a new version is available.
+*/
+NS_SWIFT_NAME(AppDistributionRelease)
+@interface FIRAppDistributionRelease : NSObject
+
+// The bundle version of this build (example: 123)
+@property(nonatomic, copy) NSString *bundleVersion;
+// The short bundle version of this build (example 1.0.0)
+@property(nonatomic, copy) NSString *bundleShortVersion;
+// The release notes for this build
+@property(nonatomic, copy) NSString *releaseNotes;
+// The URL for the build
+@property(nonatomic, strong) NSURL *downloadUrl;
+
+/** :nodoc: */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+/**
+ *  @related FIRAppDistribution
+ *
+ *  The completion handler invoked when the new build request returns.
+ *  If the call fails we return the appropriate `error code`, described by
+ *  `FIRAppDistributionError`.
+ *
+ *  @param release  The new release that is available to be installed.
+ *  @param error     The error describing why the new build request failed.
+ */
+typedef void (^FIRAppDistributionUpdateCheckCompletion)(FIRAppDistributionRelease *_Nullable release,
+                                                    NSError *_Nullable error)
+    NS_SWIFT_NAME(AppDistributionNewBuildCheckCompletion);
+
+/**
+ * The Firebase App Distribution API provides methods to check for update to
+ * the app and returns information that enables updating the app.
  *
  * By default, Firebase App Distribution is initialized with `[FIRApp configure]`.
  *
@@ -31,14 +65,28 @@ NS_SWIFT_NAME(AppDistribution)
 /** :nodoc: */
 - (instancetype)init NS_UNAVAILABLE;
 
+/**
+ * Check to see whether a new distribution is available
+ */
+- (void)checkForUpdateWithCompletion:(FIRAppDistributionUpdateCheckCompletion)completion
+    NS_SWIFT_NAME(checkForUpdate(completion:));
+
 /**
  * Accesses the singleton App Distribution instance.
  *
  * @return The singleton App Distribution instance.
  */
-+ (instancetype)appDistribution NS_SWIFT_NAME(AppDistribution());
-
++ (instancetype)appDistribution NS_SWIFT_NAME(appDistribution());
 
 @end
 
+/**
+ *  @enum FIRAppDistributionError
+ */
+typedef NS_ENUM(NSUInteger, FIRAppDistributionError) {
+  /// Unknown error.
+  FIRAppDistributionErrorUnknown = 0,
+
+} NS_SWIFT_NAME(AppDistributionError);
+
 NS_ASSUME_NONNULL_END

+ 1 - 0
FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution.h

@@ -15,3 +15,4 @@
  */
 
 #import "FIRAppDistribution.h"
+	

+ 6 - 0
FirebaseAppDistribution/Tests/UI-Prototype/authtest13.xcodeproj/project.pbxproj

@@ -15,6 +15,7 @@
 		A56F777723D15C2900ACF08D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A56F777523D15C2900ACF08D /* Main.storyboard */; };
 		A56F777923D15C2A00ACF08D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A56F777823D15C2A00ACF08D /* Assets.xcassets */; };
 		A56F777C23D15C2A00ACF08D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A56F777A23D15C2A00ACF08D /* LaunchScreen.storyboard */; };
+		A8F7294B23FDD26700AC5974 /* ViewControllerObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F7294A23FDD26700AC5974 /* ViewControllerObjC.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -29,6 +30,8 @@
 		A56F777B23D15C2A00ACF08D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		A56F777D23D15C2A00ACF08D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		A6B91791ECB838A6F0D91224 /* libPods-authtest13.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-authtest13.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+		A8F7294923FDD23900AC5974 /* ViewControllerObjC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewControllerObjC.h; sourceTree = "<group>"; };
+		A8F7294A23FDD26700AC5974 /* ViewControllerObjC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewControllerObjC.m; sourceTree = "<group>"; };
 		BF152CB77E5E26D5395732C2 /* Pods-authtest13.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-authtest13.release.xcconfig"; path = "Target Support Files/Pods-authtest13/Pods-authtest13.release.xcconfig"; sourceTree = "<group>"; };
 		F998ADF8D08388FEC1F7FF00 /* Pods-authtest13.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-authtest13.debug.xcconfig"; path = "Target Support Files/Pods-authtest13/Pods-authtest13.debug.xcconfig"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -92,6 +95,8 @@
 				A56F777A23D15C2A00ACF08D /* LaunchScreen.storyboard */,
 				A56F777D23D15C2A00ACF08D /* Info.plist */,
 				A50276D223ECA81600F2ABF2 /* Bridging-Header.h */,
+				A8F7294923FDD23900AC5974 /* ViewControllerObjC.h */,
+				A8F7294A23FDD26700AC5974 /* ViewControllerObjC.m */,
 			);
 			path = authtest13;
 			sourceTree = "<group>";
@@ -194,6 +199,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				A8F7294B23FDD26700AC5974 /* ViewControllerObjC.m in Sources */,
 				A56F777423D15C2900ACF08D /* ViewController.swift in Sources */,
 				A56F777023D15C2900ACF08D /* AppDelegate.swift in Sources */,
 				A56F777223D15C2900ACF08D /* SceneDelegate.swift in Sources */,

+ 44 - 3
FirebaseAppDistribution/Tests/UI-Prototype/authtest13/Base.lproj/Main.storyboard

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fIi-ZI-jAX">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -23,14 +23,55 @@
                                     <action selector="touch:" destination="BYZ-38-t0r" eventType="touchDown" id="2gf-V8-MOy"/>
                                 </connections>
                             </button>
+                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jEl-6P-eBG">
+                                <rect key="frame" x="165" y="446" width="75" height="30"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <state key="normal" title="Oauth"/>
+                                <connections>
+                                    <segue destination="mNy-LQ-mNd" kind="push" id="Cfb-ka-aPV"/>
+                                </connections>
+                            </button>
                         </subviews>
                         <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                         <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
                     </view>
+                    <navigationItem key="navigationItem" id="Dav-qx-6pb"/>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="137.68115942028987" y="137.94642857142856"/>
+            <point key="canvasLocation" x="794" y="472"/>
+        </scene>
+        <!--View Controller ObjC-->
+        <scene sceneID="pXV-Rt-h0C">
+            <objects>
+                <viewController id="mNy-LQ-mNd" customClass="ViewControllerObjC" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="lPH-bB-3uT">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                        <viewLayoutGuide key="safeArea" id="QDL-9a-CDY"/>
+                    </view>
+                    <navigationItem key="navigationItem" id="xlZ-A4-Gul"/>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="77p-WX-p7O" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1578" y="477"/>
+        </scene>
+        <!--Navigation Controller-->
+        <scene sceneID="zYf-fS-yZE">
+            <objects>
+                <navigationController id="fIi-ZI-jAX" sceneMemberID="viewController">
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="2bF-79-hiB">
+                        <rect key="frame" x="0.0" y="44" width="414" height="44"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </navigationBar>
+                    <connections>
+                        <segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="P06-e0-nB7"/>
+                    </connections>
+                </navigationController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="oF0-6P-uA2" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-70" y="467"/>
         </scene>
     </scenes>
 </document>

+ 22 - 1
FirebaseAppDistribution/Tests/UI-Prototype/authtest13/ViewController.swift

@@ -20,7 +20,29 @@ class ViewController: UIViewController {
 //        let sceneDelegate = self.view.window?.windowScene?.delegate as? SceneDelegate
         
         appDelegate.mainViewController = self
+        AppDistribution.appDistribution().checkForUpdate(completion: { release, error in
+            guard let release = release else {
+                return
+            }
 
+            let uialert = UIAlertController(title: "New Version Available", message: "Version \(release.bundleShortVersion) (\(release.bundleVersion)) is available.", preferredStyle: .alert)
+            
+            uialert.addAction(UIAlertAction(title: "Update", style: UIAlertAction.Style.default) {
+                UIAlertAction in
+            })
+            uialert.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel) {
+                UIAlertAction in
+            })
+            self.present(uialert, animated: true, completion: nil)
+        })
+    }
+    
+    func updateHandler(action: UIAlertAction) {
+        
+    }
+    
+    func cancelHandler(action: UIAlertAction) {
+        
     }
     
     @IBAction func touch(_ sender: Any) {
@@ -37,6 +59,5 @@ class ViewController: UIViewController {
 //        guard let url = URL(string: "https://tinyurl.com/ua8tka3") else { return}
 //        UIApplication.shared.open(url, options: [:], completionHandler: nil)
     }
-
 }
 

+ 12 - 0
FirebaseAppDistribution/Tests/UI-Prototype/authtest13/ViewControllerObjC.h

@@ -0,0 +1,12 @@
+//
+//  ViewControllerObjC.h
+//  authtest13
+//
+//  Created by Jeremy Durham on 2/19/20.
+//  Copyright © 2020 Pranav Rajgopal. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ViewControllerObjC: UIViewController
+@end

+ 38 - 0
FirebaseAppDistribution/Tests/UI-Prototype/authtest13/ViewControllerObjC.m

@@ -0,0 +1,38 @@
+//
+//  ViewControllerObjC.m
+//  authtest13
+//
+//  Created by Jeremy Durham on 2/19/20.
+//  Copyright © 2020 Pranav Rajgopal. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ViewControllerObjC.h"
+#import <FIRAppDistribution.h>
+
+@implementation ViewControllerObjC
+
+- (void)viewDidLoad:(BOOL)animated{
+    [super viewDidLoad];
+    [[FIRAppDistribution appDistribution] checkForUpdateWithCompletion:^(FIRAppDistributionRelease * _Nullable release, NSError * _Nullable error) {
+        NSLog(@"%@", release);
+        if (release) {
+            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"New Version Available"
+                                                                             message:[NSString stringWithFormat:@"Version %@ (%@) is available.",
+                                                                                      release.bundleShortVersion, release.bundleVersion]
+                                                                      preferredStyle:UIAlertControllerStyleAlert];
+            
+            UIAlertAction *updateAction = [UIAlertAction actionWithTitle:@"Update" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
+            }];
+            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
+            }];
+            
+            [alert addAction:updateAction];
+            [alert addAction:cancelAction];
+            
+            [self presentViewController:alert animated:YES completion:nil];
+        }
+    }];
+}
+
+@end

+ 1 - 1
Gemfile.lock

@@ -126,4 +126,4 @@ DEPENDENCIES
   danger (= 6.1.0)
 
 BUNDLED WITH
-   1.17.3
+   2.1.2