Skip to content

Commit

Permalink
Remove invites and bump to Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
morganchen12 committed Oct 24, 2019
1 parent 57205d7 commit 6da3dc8
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 179 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ We promise to extend courtesy and respect to everyone involved in this project r

If any member of the community violates this code of conduct, the maintainers of the Firebase Android Quickstarts project may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate.

If you are subject to or witness unacceptable behavior, or have any other concerns, please drop us a line at nivco@google.com.
If you are subject to or witness unacceptable behavior, or have any other concerns, please drop us a line at arthurthompson@google.com.

## <a name="question"></a> Got a Question or Problem?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
5F5A537A1ADE67D500F81DF0 /* FriendlyChatSwift */,
5F5A534D1ADE670C00F81DF0 /* Products */,
AD1F1C80A93A096F652504F5 /* Frameworks */,
8B7F6748719E6051BB62B7C7 /* Pods */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -105,6 +106,13 @@
name = "Supporting Files";
sourceTree = "<group>";
};
8B7F6748719E6051BB62B7C7 /* Pods */ = {
isa = PBXGroup;
children = (
);
path = Pods;
sourceTree = "<group>";
};
AD1F1C80A93A096F652504F5 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -145,7 +153,7 @@
TargetAttributes = {
5F5A53781ADE67D500F81DF0 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0900;
LastSwiftMigration = 1110;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand All @@ -159,6 +167,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -333,7 +342,7 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -353,7 +362,7 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
14 changes: 9 additions & 5 deletions ios-starter/swift-starter/FriendlyChatSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?

@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
func application(_ application: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any])
-> Bool {
return self.application(application, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: "")
return GIDSignIn.sharedInstance().handle(url)
}

func application(_ application: UIApplication,
open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation)
open url: URL,
sourceApplication: String?,
annotation: Any) -> Bool {
return GIDSignIn.sharedInstance().handle(url)
}

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
Expand All @@ -43,7 +47,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().delegate = self
return true
}
Expand Down
30 changes: 21 additions & 9 deletions ios-starter/swift-starter/FriendlyChatSwift/FCViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ let kBannerAdUnitID = "ca-app-pub-3940256099942544/2934735716"

@objc(FCViewController)
class FCViewController: UIViewController, UITableViewDataSource, UITableViewDelegate,
UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate,
InviteDelegate {
UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

// Instance variables
@IBOutlet weak var textField: UITextField!
Expand Down Expand Up @@ -128,31 +127,34 @@ class FCViewController: UIViewController, UITableViewDataSource, UITableViewDele
@IBAction func didTapAddPhoto(_ sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
picker.sourceType = UIImagePickerControllerSourceType.camera
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
picker.sourceType = UIImagePickerController.SourceType.camera
} else {
picker.sourceType = UIImagePickerControllerSourceType.photoLibrary
picker.sourceType = UIImagePickerController.SourceType.photoLibrary
}

present(picker, animated: true, completion:nil)
}

func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [String : Any]) {
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
// Local variable inserted by Swift 4.2 migrator.
let info = convertFromUIImagePickerControllerInfoKeyDictionary(info)

picker.dismiss(animated: true, completion:nil)
guard let uid = Auth.auth().currentUser?.uid else { return }

// if it's a photo from the library, not an image from the camera
if #available(iOS 8.0, *), let referenceURL = info[UIImagePickerControllerReferenceURL] as? URL {
if #available(iOS 8.0, *), let referenceURL = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.referenceURL)] as? URL {
let assets = PHAsset.fetchAssets(withALAssetURLs: [referenceURL], options: nil)
let asset = assets.firstObject
asset?.requestContentEditingInput(with: nil, completionHandler: { (contentEditingInput, info) in
let imageFile = contentEditingInput?.fullSizeImageURL
let filePath = "\(uid)/\(Int(Date.timeIntervalSinceReferenceDate * 1000))/\((referenceURL as AnyObject).lastPathComponent!)"
})
} else {
guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else { return }
let imageData = UIImageJPEGRepresentation(image, 0.8)
guard let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as? UIImage else { return }
let imageData = image.jpegData(compressionQuality: 0.8)
guard let uid = Auth.auth().currentUser?.uid else { return }
let imagePath = "\(uid)/\(Int(Date.timeIntervalSinceReferenceDate * 1000)).jpg"
}
Expand All @@ -177,3 +179,13 @@ class FCViewController: UIViewController, UITableViewDataSource, UITableViewDele
}

}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIImagePickerControllerInfoKeyDictionary(_ input: [UIImagePickerController.InfoKey: Any]) -> [String: Any] {
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIImagePickerControllerInfoKey(_ input: UIImagePickerController.InfoKey) -> String {
return input.rawValue
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import Firebase
import GoogleSignIn

@objc(SignInViewController)
class SignInViewController: UIViewController, GIDSignInUIDelegate {
class SignInViewController: UIViewController {
@IBOutlet weak var signInButton: GIDSignInButton!
var handle: AuthStateDidChangeListenerHandle?

override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance()?.presentingViewController = self
}

deinit {
Expand Down
6 changes: 3 additions & 3 deletions ios-starter/swift-starter/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ platform :ios, '9.0'
pod 'Firebase/AdMob'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Invites'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'Fabric', '~> 1.7.2'
pod 'Crashlytics', '~> 3.9.3'
pod 'Fabric'
pod 'Crashlytics'
pod 'GoogleSignIn'

target 'FriendlyChatSwift' do
end
Loading

0 comments on commit 6da3dc8

Please sign in to comment.