This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MeuFirebaseInstanceIDService extends FirebaseInstanceIdService { | |
| @Override | |
| public void onTokenRefresh() { | |
| super.onTokenRefresh(); | |
| // Obter o novo InstanceID | |
| String firebaseToken = FirebaseInstanceId.getInstance().getToken(); | |
| //Actualizar na base de dados | |
| String uid = FirebaseAuth.getInstance().getCurrentUser().getUid(); | |
| FirebaseDatabase.getInstance().getReference().child("utilizadores/"+uid+"/FirebaseToken") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const functions = require('firebase-functions'); //Constante para invocar o Firebase Cloud Functions | |
| const admin = require('firebase-admin'); //Constante para invocar o Firebase Admin SDK | |
| admin.initializeApp(functions.config().firebase); //Inicializar o Firebase com configurações do functions | |
| exports.sendFollowerNotification = functions.database.ref('/mensagens/{idDestinatario}').onWrite(event => { | |
| const idDestinatario = event.params.idDestinatario; | |
| const conversa = event.data.val(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <service | |
| android:name=".MeuFirebaseMessagingService"> | |
| <intent-filter> | |
| <action android:name="com.google.firebase.MESSAGING_EVENT"/> | |
| </intent-filter> | |
| </service> | |
| <service | |
| android:name=".MeuFirebaseInstanceIDService"> | |
| <intent-filter> | |
| <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "mensagens" : { | |
| "idDestinatario123" : { | |
| "emissor" : "id123456", | |
| "mensagem" : "Novo artigo sobre Firebase :)" | |
| }, | |
| "idDestinatario234" : { | |
| "emissor" : "id231297", | |
| "mensagem" : "Thanks :D" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public void onResult(AIResponse response) { | |
| Result result = response.getResult(); | |
| // Obter os parametros caso existam | |
| String parameterString = ""; | |
| if (result.getParameters() != null && !result.getParameters().isEmpty()) { | |
| for (final Map.Entry<String, JsonElement> entry : result.getParameters().entrySet()) { | |
| parameterString += "(" + entry.getKey() + ", " + entry.getValue() + ") "; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const functions = require('firebase-functions'); //Constante para invocar o Firebase Cloud Functions | |
| const admin = require('firebase-admin'); //Constante para invocar o Firebase Admin SDK | |
| admin.initializeApp(functions.config().firebase); //Inicializar o Firebase com configurações do functions | |
| // Keeps track of the length of the 'likes' child list in a separate property. | |
| exports.contarGrupos = functions.database.ref("/usuarios_grupos/{uid}/grupos/{grupoid}").onWrite((event) => { | |
| //O que acontece quando há uma nova escrita no nó especificado | |
| var gruposRef = event.data.ref.parent; //Obter a referencia dos grupos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.rosariopfernandes.meuassistentepessoal; | |
| import android.os.Bundle; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.support.v7.widget.Toolbar; | |
| import android.view.View; | |
| import android.widget.Button; | |
| import android.widget.TextView; | |
| import com.google.gson.JsonElement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:fitsSystemWindows="true" | |
| tools:context="io.github.rosariopfernandes.meuassistentepessoal.MainActivity"> | |
| <android.support.design.widget.AppBarLayout |
NewerOlder