Docsity

P2P cloud computing decentralizes data and computational tasks across multiple devices, im, Cheat Sheet of Computer Communication Systems

Partial preview of the text

Download P2P cloud computing decentralizes data and computational tasks across multiple devices, im and more Cheat Sheet Computer Communication Systems in PDF only on Docsity!

Cosc 5/

Firebase

  • (^) It's basically middle ware that allows you do a number of things cross platform
    • (^) Analytics
      • (^) is a free and unlimited analytics tool to help you get insight on app usage and user engagement. No extra code needed, only console.
    • Cloud Messaging (covered in another lecture)
      • (^) Firebase Cloud Messaging lets you deliver and receive messages across platforms reliably.
    • (^) Notifications
      • helps you re-engage with users at the right moment. No extra code needed, only console
    • (^) Authentication
      • (^) a key feature for protecting the data in your database and storage.
    • Realtime Database
      • (^) lets you sync data across all clients in realtime and remains available when your app goes offline.
    • (^) Cloud Firestore (new database, just out of beta)
      • Combines cloud database and functions together. Uses a scalable NoSQL cloud database to store and sync data.
    • (^) Storage
      • (^) lets you store and serve user-generated content, such as photos or videos. Firebase Storage is backed by Google Cloud Storage

What is firebase

  • (^) Beta products
    • (^) ML Kit
      • (^) "use machine learning to solve problems." Currently, it is just the Vision APIs for text recognition, face detection, barcode scanning, image labeling, and landmark recognition. But this would use the cloud based systems instead of just the device cpu.
    • (^) A/B Testing
      • (^) Let you optimize your app experience based on analytics. Change it for different demographics, make it different experience for say a teenage group verses a retired group. Without having to deploy two version of the app. Needs remote config.
      • (^) Deploy a new feature to a group and evaluate the effect of the changes on app use.
    • (^) Predictions
      • (^) Uses remote config, providing a custom experience based on each of your users' predicted behavior.
      • (^) You can use Predictions with the Notifications composer to deliver the right message to the right user groups.

What is firebase (3)

• Google has a number of "consoles".

  • (^) These are webpages to control varying things.
    • (^) Other Examples:
      • (^) https://partner.android.com/things/console#/ android things
      • (^) https://console.developers.google.com/apis/ for apis like maps
      • (^) https://developers.google.com/beacons/dashboard/ for beacons

• Firebase has it's own as well.

  • (^) https://console.firebase.google.com/

Firebase console

In Studio (this is setup the the Realtime Database)

In the browser Back in Studio

• Create a project and

• add the app project

Through the console only

• You need to only add firebase to the

dependencies.

  • (^) implementation 'com.google.firebase:firebase-core:16.0.7'
  • (^) The rest is done within the https://console.firebase.google.com/
  • (^) You can look many different things, from first time usage, how long the app is up, demographics of users, etc.
  • (^) Data updates once every 24 hours.

Analytics

  • (^) You create a message in the notifications

section.

  • (^) Send the message.
  • (^) It will then show up on the device as a

notification.

  • (^) If they click the notification it will launch you app.
  • (^) Note, if the app is up then the users won't see it (without extra code from cloud messaging).

Notifications (2)

• Is a cloud based database with live connections to the

app.

  • (^) The data is stored a json objects and is only intended for text, to allow for fast responses.
  • (^) Authentication is needed.
  • (^) Works even offline, with cached data then sync when online.
  • (^) dependencies
    • (^) implementation 'com.google.firebase:firebase-database:16.0.6'

Realtime Database

• Setup a connection and reference.

  • (^) FirebaseDatabase database = FirebaseDatabase.getInstance();
  • (^) DatabaseReference dbReference = database.getReference().child("messages");

• To add a new value use the push and setValue

  • (^) dbReference.push().setValue( friendlyMessage);
    • (^) Where friendlyMessage is a object holding the data.

Database setup and use.

  • (^) Listener for new data ChildEventListener mChildEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { FriendlyMessage friendlyMessage = dataSnapshot.getValue(FriendlyMessage.class); //now do something with the data } public void onChildChanged(DataSnapshot dataSnapshot, String s) { } public void onChildRemoved(DataSnapshot dataSnapshot) { } public void onChildMoved(DataSnapshot dataSnapshot, String s) { } public void onCancelled(DatabaseError databaseError) { } }; mMessagesDatabaseReference.addChildEventListener(mChildEventListener);
  • (^) Don’t forget to remove listeners in onPause, add them in onResume

Database setup and use. (2)

• By default only authenticated users can read and write

the database.

• Console:

Database and security

• It can be changed, but not recommend.

• You can setup very complex rules, where only some

users can access data, etc. With cascading rules for the

depth of nodes.

• See the documentation:

  • (^) https://firebase.google.com/docs/database/security/quickstart

Database and security (2)