This is a seed application to help you get started building OSX apps in Objective-C with Firebase. If you don't already have a Firebase account, sign up for free today!
To get started with this seed app, follow the instructions below:
git clone https://github.com/firebase/seed-osx.git
cd seed-osx
pod install
open Seed\ OSX.xcworkspace
Change line 32 of ViewController.m
to the name of your Firebase Application:
self.ref = [[Firebase alloc] initWithUrl:@"https://<YOUR-FIREBASE-APP>.firebaseio.com"];
You can then delete the #error Message
on line 31.
Once Seed OSX.xcworkspace
has been opened, press cmd + r
to run your appplication on the desktop.
This app makes use of Firebase's email & password authentication. To enable email & password auth, navigate to the "Login & Auth" tab in your Firebase app dashboard and select "Enable Email & Password Authentication".
Once it's enabled, the toggleAuth
and authOrCreateUser: password:
methods will log users in, log users out, and create a user if one needs to be created. Additionally, an Firebase is observing the auth state and will update that state with the current user's email address in the title of the NSWindow
.
Firebase also supports authentication with Facebook, Twitter, GitHub, Google, anonymous auth, and custom authentication. Check out the docs on user authentication for details on these authentication methods.
This app makes use of a NSTextField
for text input, and uses the NSControlTextEditingDelegate
control: textShouldEndEditing:
method to push messages to the /messages
node of your Firebase database. These messages are of the form:
{
email: 'email@domain.com',
text: 'Literally cronut post-ironic, shabby chic distillery PBR&B.'
}
For more information on saving data to Firebase, check out our saving data docs.
This app uses standard FEventTypeChildAdded
events to add messages to an NSMutableArray
containing FDataSnapshots
. These snapshots are provided by the NSTableViewDataSource
to populate a MessageTableViewCell
in the NSTableView
. For more information on how to view changes from Firebase, check out our retrieving data docs.
Copy and paste the contents of rules.json
into the Security & Rules tab of your Firebase App Dashboard.
rules.json
has two basic security rules. The first ensures that only logged in users can add messages to the list:
".write": "auth != null"
The second rule ensures that new messages are not empty:
".validate": "newData.hasChildren(['email', 'text'])"
.validate
rules are run after .write
rules succeed. You can see the full rules in the rules.json
file.
For more details on security rules, check out the security quickstart in our documentation.
In XCode, simply cmd + r
to run your application on your desktop.
For more information on deploying your app to the Mac App Store, or on your own, check out Apple's Distributing your Mac Apps.
The top level of the repo contains project metadata, including the README
, CONTRIBUTORS
, and LICENSE
.
Additionally, it contains Seed OSX
, which contains all of the source code for the project.
In terms of project metadata, Seed OSX.xcodeproj
is the XCode project file, and Podfile
is the Cocoapods Podfile, where our dependencies live.
rules.json
contains the security rules for the project. For more information, see the Securing your App section of this README.
Firebase has an active developer community consisting of over 230,000 developers. There are a number of different channels for contributing to our community, including:
Additional information on the community, help, or support can be found on our help page.
We'd love to accept your sample apps and patches! Before we can take them, we a few business items to take care of including our CLA and an overview of our contribution process. Please view CONTRIBUTING.md for more information.
- Submit an issue describing your proposed change to the repo in question.
- The repo owner will respond to your issue promptly.
- If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
- Fork the desired repo, develop and test your code changes.
- Ensure that your code adheres to the existing style of the library to which you are contributing.
- Ensure that your code has an appropriate set of unit tests which all pass.
- Submit a pull request.