first_open
in_app_purchase
firebase.initializeApp()
// DON'T DO THIS ANYMORE! switch (location.hostname) { case 'myapp.com': firebase.initializeApp(prodConfig); break; case 'myapp-staging.com': firebase.initializeApp(stagingConfig); break; default: firebase.initializeApp(devConfig); break; }
script
<!doctype html> <html> <body> ... <!-- Import and initialize the Firebase SDK --> <script src="/__/firebase/3.7.4/firebase-app.js"></script> <script src="/__/firebase/3.7.4/firebase-auth.js"></script> <script src="/__/firebase/init.js"></script> <script> // The Firebase SDK is ready to rock! firebase.auth().onAuthStateChange(function(user) { /* … */ }); </script> </body> </html>
firebase serve
/__/firebase/{VERSION}/firebase-{app,auth,database,messaging,storage}.js
/__/firebase/{VERSION}/firebase.js
/__/firebase/init.js
/__/firebase/init.json
init.js
3.6.0
firebase deploy
firebase login --reauth
firebase setup:web
firebase-tools
$ npm install --save firebase-tools@^3.6
const fbcli = require('firebase-tools'); const fs = require('fs'); // by default, uses the current project and logged in user fbcli.setup.web().then(config => { fs.writeFileSync( 'build/initFirebase.js', `firebase.initializeApp(${JSON.stringify(config)});` ); }); // alternatively, you can pass project or token information fbcli.setup.web({ project: 'my-custom-project', token: process.env.FIREBASE_TOKEN });
blogs/endpointslambda/aeflex-endpoints/
@app.route('/processmessage', methods=['POST']) def process(): """Process messages with information about S3 objects""" message = request.get_json().get('inputMessage', '') # add other processing as needed # for example, add event to PubSub or # download object using presigned URL, save in Cloud Storage, invoke ML APIs return jsonify({'In app code for endpoint, received message': message})
host: "echo-api.endpoints.aeflex-endpoints.cloud.goog"
inputMessage
# This section configures the processmessage endpoint. "/processmessage": post: description: "Process the given message." operationId: "processmessage" produces: - "application/json" responses: 200: description: "Return a success response" schema: $ref: "#/definitions/successMessage" parameters: - description: "Message to process" in: body name: inputMessage required: true schema: $ref: "#/definitions/inputMessage" security: - api_key: [] definitions: successMessage: properties: message: type: string inputMessage: # This section contains information about the S3 bucket and object to be processed. properties: Bucket: type: string ObjectKey: type: string ContentType: type: string ContentLength: type: integer ETag: type: string PresignedUrl: type: string
gcloud service-management deploy openapi.yaml
Service Configuration [2017-03-05r2] uploaded for service "echo-api.endpoints.aeflex-endpoints.cloud.goog"
endpoints_api_service: # The following values are to be replaced by information from the output of # 'gcloud service-management deploy openapi.yaml' command. name: echo-api.endpoints.aeflex-endpoints.cloud.goog config_id: 2017-03-05r2
gcloud app deploy
blogs/endpointslambda/lambdafunctioninline.py.
from __future__ import print_function import boto3 import json import os import urllib import urllib2 print('Loading function') s3 = boto3.client('s3') endpoint_api_key = os.environ['ENDPOINT_API_KEY'] endpoint_url = "https://aeflex-endpoints.appspot.com/processmessage" def lambda_handler(event, context): # Get the object information from the event bucket = event['Records'][0]['s3']['bucket']['name'] object_key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'].encode('utf8')) try: # Retrieve object metadata response = s3.head_object(Bucket=bucket, Key=object_key) # Generate pre-signed URL for object presigned_url = s3.generate_presigned_url('get_object', Params = {'Bucket': bucket, 'Key': object_key}, ExpiresIn = 3600) data = {"inputMessage": { "Bucket": bucket, "ObjectKey": object_key, "ContentType": response['ContentType'], "ContentLength": response['ContentLength'], "ETag": response['ETag'], "PresignedUrl": presigned_url } } headers = {"Content-Type": "application/json", "x-api-key": endpoint_api_key } # Invoke Cloud Endpoints API request = urllib2.Request(endpoint_url, data = json.dumps(data), headers = headers) response = urllib2.urlopen(request) print('Response text: {} \nResponse status: {}'.format(response.read(), response.getcode())) return response.getcode() except Exception as e: print(e) print('Error integrating lambda function with endpoint for the object {} in bucket {}'.format(object_key, bucket)) raise e
“La implementación de los anuncios con premio de AdMob no solo nos ayudó a implementar la monetización con usuarios que no gastan dinero, sino también a aumentar los ingresos totales del juego, incluidos los que se generan por CDA. A su vez, la mediación de AdMob nos permitió comparar fácilmente el rendimiento de nuestros anuncios en redes de anuncios”.
“Los videos con premio de AdMob tuvieron un excelente rendimiento en todas las redes en términos de velocidad de relleno y eCPM, en nuestros mercados principales. Gracias a la implementación de anuncios de video con premio en espacios adecuados de nuestras apps de juegos, la captación de usuarios que observamos es aun mejor”.
“La implementación de los anuncios con premio de AdMob no solo nos ayudó a implementar la monetización con usuarios que no gastan dinero, sino también a aumentar los ingresos totales del juego, incluidos los que se generan por CDA. A su vez, la mediación de AdMob nos permitió comparar fácilmente el rendimiento de nuestros anuncios en redes de anuncios”. - Somin Oh, administrador de Monetización de Anuncios de JoyCity
git clone https://github.com/firebase/functions-cron
cd functions-cron
gcloud config set project
appengine/
cd appengine/
$ pip install -t lib -r requirements.txt
gcloud app create
gcloud app deploy app.yaml \ cron.yaml
/_ah/start
cd ..
hourly_job
firebase deploy --only functions --project
index.js
/publish/hourly-tick
firebase functions:log --project
console.log
hourly-tick
daily-tick
weekly-tick