Skip to main content

C++ Firebase extension for 3D and 2D games.

Project description

igeFirebase

C++ extension Firebase for 3D and 2D games.

Before running this tutorial, you have to install igeFirebase

[pip install igeFirebase]

Available libraries

- Admob [ Android / iOS ]
- Analytics [ Android / iOS ]
- Authentication [ Android / iOS / Desktop ]
- RemoteConfig [ Android / iOS / Desktop ]
- MLKit [ Android ]

Functions

Firebase

  • First, you need to import and init the firebase system
     import igeFirebase
     igeFirebase.init()
    
  • Release it when everything is done
     igeFirebase.release()
    

Firebase Admob

https://firebase.google.com/docs/admob/cpp/quick-start

  • First, init the firebase admob system

    • Following the structure : "adMobApp","bannerSize", "gender", "childDirectedTreatment","keywords","birthday", "testDevicesIds"
    • Tuple is supported
     fb_admob = igeFirebase.admob()
     fb_admob.init(("ca-app-pub-1009273426450955~3020262852", "ca-app-pub-3940256099942544/6300978111", "ca-app-pub-3940256099942544/1033173712", "ca-app-pub-3940256099942544/2888167318"), (320, 50), 1, 1, ("game", "games", "gamess", "gamesss"), (12, 11, 1988), ("112F1C63CDDE8BAAEE287FDE3BA4C662",))
    
  • Showing the ads

    • Banner
    Position MoveTo Enum
    Top of the screen, horizontally centered. kPositionTop = 0,
    Bottom of the screen, horizontally centered. kPositionBottom,
    Top-left corner of the screen. kPositionTopLeft,
    Top-right corner of the screen. kPositionTopRight,
    Bottom-left corner of the screen. kPositionBottomLeft,
    Bottom-right corner of the screen. kPositionBottomRight,
     fb_admob.showBanner()
     fb_admob.bannerMoveTo(0)
     fb_admob.bannerMoveTo(1)
     fb_admob.bannerMoveTo(2)
     fb_admob.bannerMoveTo(3)
     fb_admob.bannerMoveTo(4)
     fb_admob.bannerMoveTo(5)
     fb_admob.hideBanner()
    
    • Interstitial
     fb_admob.showInterstitial()
    
    • RewardedVideo
     fb_admob.showRewardedVideo()
     fb_admob.pauseRewardedVideo()
     fb_admob.resumeRewardedVideo()
    
  • Release it when everything is done

     fb_admob.release()
    

Firebase Analytics

https://firebase.google.com/docs/analytics/cpp/events

  • First, init the firebase admob system
     fb_analytics = igeFirebase.analytics()
     fb_analytics.init()
    
  • Sending the events
     fb_analytics.setUserProperty("sign_up_method", "google")
     fb_analytics.setUserId("uber_user_510")
     fb_analytics.setCurrentScreen("Firebase Analytics C++ testapp", "testapp")
    
     fb_analytics.logEvent("login")
     fb_analytics.logEvent("progress", "percent", 0.4)
     fb_analytics.logEvent("post_score", "score", 42)
     fb_analytics.logEvent("join_group", "group_id", "spoon_welders")
    
     levelUpParameters = (("level", 5), ("character", "mrspoon"), ("hit_accuracy", 3.14))
     fb_analytics.logEvent("level_up", levelUpParameters)
    
  • Release it when everything is done
     fb_analytics.release()
    

Firebase Authentication

https://firebase.google.com/docs/auth/cpp/start

  • First, init the firebase admob system
     fb_auth = igeFirebase.auth()
     fb_auth.init()
    
  • Authenticate
     print('signInWithEmailAndPassword : ' + str(fb_auth.signInWithEmailAndPassword("doan.do@indigames.net", "doan.do")))
     print('isPlayerAuthenticated : ' + str(fb_auth.isPlayerAuthenticated()))
    
     print('signOut : ' + str(fb_auth.signOut()))
     print('isPlayerAuthenticated : ' + str(fb_auth.isPlayerAuthenticated()))
    
     print('registerWithEmailAndPassword : ' + str(fb_auth.registerWithEmailAndPassword("dodoan.it@gmail.com", "indigames")))
     print('isPlayerAuthenticated : ' + str(fb_auth.isPlayerAuthenticated()))
    
  • Release it when everything is done
     fb_auth.release()
    

Firebase MLKit

https://firebase.google.com/docs/ml-kit

  • First, init the firebase mlkit system
     fb_mlkit = igeFirebase.mlKit()
     fb_mlkit.init(mode)	// 1 = FAST ; 2 = ACCURATE
    
  • API
     fb_mlkit.getCameraSize()				// result : tuple(w, h)
     fb_mlkit.getCameraData()				// result : list(unsigned char)
     fb_mlkit.getContours					// result : list(float)
     fb_mlkit.getLeftEyeOpenProbability		// Returns a value between 0.0 and 1.0 giving a probability that the face's left eye is open
     fb_mlkit.getRightEyeOpenProbability		// Returns a value between 0.0 and 1.0 giving a probability that the face's right eye is open
    
  • Release it when everything is done
     fb_mlkit.release()
    

Firebase Firestore

  • callback

     def FirestoreGetCB(self, collection, field, value):
         print(self, 'get --- collection=' + collection + ' field=' + str(field) + ' value=' + str(value))
    
     def FirestoreSetCB(self, collection, field, value):
         print(self, 'set --- collection=' + collection + ' field=' + str(field) + ' value=' + str(value))
    
     def FirestoreDeleteCB(self, collection, field=None, value=None):
         print(self, 'del --- collection=' + collection + ' field=' + str(field) + ' value=' + str(value))
    
  • get

    get data with Cloud Firestore

    firestore().get(collection, field, callback)

    collection : string

    field : string or None

    callback : function(collection, field, value)

    value : (string, int, double, dictionary)

    Example

     igeFirebase.firestore().get("users", "str_s", self.FirestoreGetCB)
     igeFirebase.firestore().get("users", "int_s", self.FirestoreGetCB)
     igeFirebase.firestore().get("users", "double_s", self.FirestoreGetCB)
     igeFirebase.firestore().get("users", "bool_s", self.FirestoreGetCB)
     igeFirebase.firestore().get("users", "map_s", self.FirestoreGetCB)
     igeFirebase.firestore().get("users", None, self.FirestoreGetCB)
    
  • set

    add data to Cloud Firestore

    firestore().set(collection, field, value, callback, timestamp)

    collection : string

    field : string

    value : (string, int, double, dictionary)

    callback : optional function(collection, field, result)

    timestamp : bool(optinal)

    Example

     igeFirebase.firestore().set("users", "str_s", "str_s", self.FirestoreSetCB)
     igeFirebase.firestore().set("users", "int_s", 1212, self.FirestoreSetCB)
     igeFirebase.firestore().set("users", "double_s", 12.1, self.FirestoreSetCB)
     igeFirebase.firestore().set("users", "bool_s", True, self.FirestoreSetCB)
     igeFirebase.firestore().set("users", "map_s", {"map_bool_s": True, "map_double_s": 12.1, "map_int_s": 1212, "map_str_s": "map_str_s"}, self.FirestoreSetCB)
     igeFirebase.firestore().set("users", "timestampValue", 10, self.FirestoreSetCB, timestamp=True)
     igeFirebase.firestore().set("users", "timestamp", None, self.FirestoreSetCB, timestamp=True)
    
  • delete

    delete data from Cloud Firestore

    firestore().delete(collection, field, callback)

    collection : string

    field : string or None

    callback : optional function(collection, field, result)

    Example

     igeFirebase.firestore().delete("users", "bool_s", self.FirestoreDeleteCB)
     igeFirebase.firestore().delete("users", None, self.FirestoreDeleteCB)
    

Notes

- Firebase C++ SDK desktop support is a beta feature so only a subset of features supported for now.
	- Authentication
	- Cloud Functions
	- Cloud Storage
	- Realtime Database
	- Remote Config
	- Firestore [TODO]

Reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

igeFirebase-0.2.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

igeFirebase-0.2.0-cp39-cp39-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

File details

Details for the file igeFirebase-0.2.0.tar.gz.

File metadata

  • Download URL: igeFirebase-0.2.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for igeFirebase-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5d7e17d2afd7d4658e56791fe06b944876f73dc54fd19fb70f1826b5aa323c05
MD5 4b53efa2052a47dcd8bf9daa982f0176
BLAKE2b-256 83428e9e294cdc7f0d1af40ea7f646657001e0a64e84738584918fdfcbb7eead

See more details on using hashes here.

File details

Details for the file igeFirebase-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: igeFirebase-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for igeFirebase-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d3c5be9d2fcef8d86291e5d4672662295ddcc5020c3043618c02b5aebfbe638e
MD5 1ab06ac62d2ea6f01626ec81a1833407
BLAKE2b-256 fcaa7884bbf403688b491b9d338eca3b9fd68321d8cdb62b043410747d8b3143

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page