Skip to content

Commit

Permalink
New native (#31)
Browse files Browse the repository at this point in the history
* Remove FIR cpp SDK (#30)

* initial fix

* implements ios

* add constants

* rename constants

* fix constants

* update docs

* update documentation

* fix manual

* fix  log() function on ios

* rewrite table for android

* android cleanup

* implement iOS and add validity check

* fix platform name for actions

---------

Co-authored-by: Sippul <[email protected]>
  • Loading branch information
AGulev and Sippul authored Jan 18, 2024
1 parent 844b78d commit 675e79e
Show file tree
Hide file tree
Showing 31 changed files with 2,852 additions and 690 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
build_with_bob_macos:
strategy:
matrix:
platform: [arm64-darwin, x86_64-darwin]
platform: [arm64-ios, x86_64-darwin]
runs-on: macOS-latest

name: Build
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ google-services.xml
dependencies.json
GoogleService-Info.plist
Info.plist
/debug.keystore
/debug.keystore.pass.txt
/manifest.private.der
/manifest.public.der
3 changes: 3 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Follow guide in https://github.com/defold/extension-firebase

Download Firebase C++ SDK download link: https://firebase.google.com/download/cpp
Copy `firebase_cpp_sdk/include/firebase/analytics/*.*` to `include/firebase/analytics/` in extension. Make sure new constant registered in Lua.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[![Actions Status Alpha](https://github.com/defold/extension-firebase-analytics/actions/workflows/bob.yml/badge.svg)](https://github.com/defold/extension-firebase-analytics/actions)

![](https://img.shields.io/badge/Firebase%20CPP%20SDK-8.10.0-green)
![](https://img.shields.io/badge/Firebase%20iOS%20SDK-8.13.0-green)

# Firebase Analytics for Defold

Defold [native extension](https://www.defold.com/manuals/extensions/) that integrates [Firebase Analytics](https://firebase.google.com/docs/analytics) functionality on Android and iOS.
Expand Down
Binary file added docs/add-dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 39 additions & 27 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,64 @@ This extension allows you to interact with Firebase Analytics in a uniform way f


## Installation
To use this library in your Defold project, add the following URLs to your `game.project` dependencies:
To use Firabase in your Defold project, add a version of the Firebase extension to your `game.project` dependencies from the list of available [Firebase Releases](https://github.com/defold/extension-firebase/releases) and corresponding [Firebase Config Release](https://github.com/defold/extension-firebase-remoteconfig/releases).
Find the version you want for both extensions, copy the URLs to ZIP archive of the release and add it to the project dependencies.


| Firebase C++ SDK | Firebase iOS SDK | Dependencies |
|-------------------------|-------------------------|--------------|
| Firebase C++ SDK 8.10.0 | Firebase iOS SDK 8.13.0 |[https://github.com/defold/extension-firebase/archive/refs/tags/1.4.2.zip](https://github.com/defold/extension-firebase/archive/refs/tags/1.4.2.zip)<br>[https://github.com/defold/extension-firebase-analytics/archive/refs/tags/2.2.0.zip](https://github.com/defold/extension-firebase-analytics/archive/refs/tags/2.2.2.zip) |
![](add-dependency.png)


## Setup
Follow the [main setup guide for integration of Firebase in Defold](https://www.defold.com/extension-firebase).



## Usage

```lua
function init(self)
-- use firebase only if it is supported on the current platform
if not firebase then
local function firebase_analytics_callback(self, message_id, message)
if message_id == remoteconfig.MSG_ERROR then
-- an error was detected when performing an analytics config operation
print("Firebase Analytics Config error: ", message.error)
return
end

-- initialise firebase and check that it was successful
local ok, err = firebase.init()
if not ok then
print(err)
if message_id == remoteconfig.MSG_INSTANCE_ID then
-- result of the firebase.analytics.get_id() call
print("Firebase Analytics Config instance_id: ", message.instance_id)
return
end
end

-- initialise analytics
firebase.analytics.init()

-- log data
firebase.analytics.set_screen("myscreen", "collection")
firebase.analytics.log_string("character", "storm trooper")
firebase.analytics.log_int("kills", 152)
firebase.analytics.log_number("speed", 1.15)
local t = {
number = math.random(1,100),
boolean = true,
string = "some_string"
}
firebase.analytics.log_table("stats", t)
function init(self)
-- use firebase only if it is supported on the current platform
if not firebase then
return
end

-- initialise firebase and check that it was successful
firebase.set_callback(function(self, message_id, message)
if message_id == firebase.MSG_INITIALIZED then
firebase.remoteconfig.set_callback(firebase_analytics_callback)
firebase.analytics.initialize()

-- log data
firebase.analytics.log_string("character", "storm trooper")
firebase.analytics.log_int("kills", 152)
firebase.analytics.log("tutorial_done")
firebase.analytics.log_number("speed", 1.15)
local t = {
number = math.random(1,100),
boolean = true,
string = "some_string"
}
firebase.analytics.log_table("stats", t)
firebase.analytics.get_id()
end
end)
end
```

Read about [events](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event) and [parameters](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param) naming limitations in the official documentation.

## Source code

The source code is available on [GitHub](https://github.com/defold/extension-firebase-analytics)
Expand Down
Loading

0 comments on commit 675e79e

Please sign in to comment.