Skip to content

Commit

Permalink
add storage to firebase codelab ios
Browse files Browse the repository at this point in the history
Change-Id: I26dde8156c8702970ac44800f7ecc5721daaeda2
  • Loading branch information
ulukaya committed Mar 10, 2016
1 parent ce01e80 commit 4997582
Show file tree
Hide file tree
Showing 42 changed files with 713 additions and 190 deletions.
51 changes: 47 additions & 4 deletions ios-starter/objc-starter/FriendlyChatObjC/FCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "Constants.h"
#import "FCViewController.h"

#import "FirebaseStorage.h"
@import FirebaseDatabase;
@import FirebaseApp;
@import FirebaseAuth;
Expand All @@ -27,10 +28,9 @@
@import Firebase.CrashReporting;

@interface FCViewController ()<UITableViewDataSource, UITableViewDelegate,
UITextFieldDelegate> {
UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
int _msglength;
FirebaseHandle _refHandle;
UInt32 _userInt;
}

@property(nonatomic, weak) IBOutlet UITextField *textField;
Expand All @@ -41,6 +41,7 @@ @interface FCViewController ()<UITableViewDataSource, UITableViewDelegate,

@property (strong, nonatomic) Firebase *ref;
@property (strong, nonatomic) NSMutableArray<FDataSnapshot *> *messages;
@property (strong, nonatomic) FIRStorage *storageRef;

@end

Expand All @@ -57,14 +58,13 @@ - (IBAction)didPressCrash:(id)sender {
- (void)viewDidLoad {
[super viewDidLoad];

_userInt = arc4random();
_msglength = 10;
_messages = [[NSMutableArray alloc] init];

[self loadAd];
[_clientTable registerClass:UITableViewCell.self forCellReuseIdentifier:@"tableViewCell"];
[self fetchConfig];

[self configureStorage];
}

- (void)loadAd {
Expand All @@ -73,6 +73,9 @@ - (void)loadAd {
- (void)fetchConfig {
}

- (void)configureStorage {
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(nonnull NSString *)string {
NSString *text = textField.text;
if (!text) {
Expand Down Expand Up @@ -102,9 +105,49 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(n

// UITextViewDelegate protocol methods
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
data[MessageFieldstext] = textField.text;
[self sendMessage:data];
textField.text = @"";
return YES;
}

- (void)sendMessage:(NSDictionary *)data {
}

# pragma mark - Image Picker

- (IBAction)didTapAddPhoto:(id)sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}

[self presentViewController:picker animated:YES completion:NULL];
}

- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:NULL];

NSURL *referenceUrl = info[UIImagePickerControllerReferenceURL];
PHFetchResult* assets = [PHAsset fetchAssetsWithALAssetURLs:@[referenceUrl] options:nil];
PHAsset *asset = [assets firstObject];
[asset requestContentEditingInputWithOptions:nil
completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
NSString *imageFile = [contentEditingInput.fullSizeImageURL absoluteString];
NSString *fileName = [[AppState sharedInstance].displayName stringByAppendingString:[referenceUrl lastPathComponent]];
}
];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}

- (IBAction)signOut:(UIButton *)sender {
[AppState sharedInstance].signedIn = false;
[self performSegueWithIdentifier:SeguesFpToSignIn sender:nil];
Expand Down
96 changes: 55 additions & 41 deletions ios-starter/objc-starter/FriendlyChatObjC/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images": [
{
"filename": "ic_camera.png",
"filename": "ic_add_a_photo.png",
"idiom": "universal",
"scale": "1x"
},
{
"filename": "ic_camera_2x.png",
"filename": "ic_add_a_photo_2x.png",
"idiom": "universal",
"scale": "2x"
},
{
"filename": "ic_camera_3x.png",
"filename": "ic_add_a_photo_3x.png",
"idiom": "universal",
"scale": "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1024C2EB1C8F6E3000945A88 /* BridgingHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; };
1037935F1BF4256400C88958 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = Pods/Firebase/Headers/module.modulemap; sourceTree = "<group>"; };
107960721C612531003DB6CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
107960741C61253B003DB6CC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -93,6 +94,7 @@
children = (
107960711C612531003DB6CC /* Main.storyboard */,
107960741C61253B003DB6CC /* Info.plist */,
1024C2EB1C8F6E3000945A88 /* BridgingHeader.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand All @@ -112,9 +114,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 5F5A53991ADE67D500F81DF0 /* Build configuration list for PBXNativeTarget "FriendlyChatSwift" */;
buildPhases = (
0ADC761F10B55C3FB4BE992D /* 📦 Check Pods Manifest.lock */,
5F5A53751ADE67D500F81DF0 /* Sources */,
5F5A53761ADE67D500F81DF0 /* Frameworks */,
5F5A53771ADE67D500F81DF0 /* Resources */,
B3BF01B06E7C1514CF9C5F57 /* 📦 Embed Pods Frameworks */,
D9BEACE6EFCA2932E5D1AC28 /* 📦 Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -178,6 +183,54 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0ADC761F10B55C3FB4BE992D /* 📦 Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
B3BF01B06E7C1514CF9C5F57 /* 📦 Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FriendlyChatSwift/Pods-FriendlyChatSwift-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
D9BEACE6EFCA2932E5D1AC28 /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FriendlyChatSwift/Pods-FriendlyChatSwift-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
5F5A53751ADE67D500F81DF0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -304,7 +357,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.codelab.FriendlyChatSwift;
PRODUCT_NAME = FriendlyChatSwift;
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OBJC_BRIDGING_HEADER = FriendlyChatSwift/BridgingHeader.h;
};
name = Debug;
};
Expand All @@ -321,7 +374,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.codelab.FriendlyChatSwift;
PRODUCT_NAME = FriendlyChatSwift;
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OBJC_BRIDGING_HEADER = FriendlyChatSwift/BridgingHeader.h;
};
name = Release;
};
Expand Down
Loading

0 comments on commit 4997582

Please sign in to comment.