Initialize the Fire SDK on Unity for IOS - android

I just started a project in Unity and I integrated FireBase Analytics.
After some problems I was able to get data from IOS and Android devices so I added some custom events.
I followed the instructions from here and I stared to see results in the dashboard . My problem is that I'm not sure if both IOS and Android are sending the events and I don't know how to separate the event in the dashboard. I'm particularly concerned because I'm not sure if I misunderstood this line of the instructions:
The Firebase Unity SDK on Android requires Google Play services, which must be up-to-date before the SDK can be used. The following code should be added at the start of your application to check for and optionally update Google Play ....
I assumed that the following code had to be added ONLY for Android so I didn't add it to IOS. Can you tell me if I had add this code for IOS too? and how can I check the events for every OS?
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
// Create and hold a reference to your FirebaseApp, i.e.
// app = Firebase.FirebaseApp.DefaultInstance;
// where app is a Firebase.FirebaseApp property of your application class.
// Set a flag here indicating that Firebase is ready to use by your
// application.
} else {
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
Thank you in advance

Well, I was looking for all the day and I found that the filter between OS is in the top left corner of dashboard and event tap as well.
I also used the code for both IOS and Android and I started to get custom event in IOS too.

Related

Disable Advertising ID (AAID) collection runtime in Unity Firebase SDK

The new Google policy requires app to not transmit Android Advertising ID when targeting for both children and adults. Is there any option that we can disable it in runtime based on user preference? I found only this doc about disabling the AAID permanently using meta-data in AndroidManifest.xml https://firebase.google.com/docs/analytics/configure-data-collection?platform=android. I'm currently using Unity Firebase SDK at the moment and it does not seem like there's an option for it nor Android native Firebase SDK.
You can find this used in Firebase unity sample MechaHamster in Startup.cs file, here how they used it:
// Start gathering analytic data.
void InitializeAnalytics() {
Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
// Set the user's sign up method.
Firebase.Analytics.FirebaseAnalytics.SetUserProperty(
Firebase.Analytics.FirebaseAnalytics.UserPropertySignUpMethod,
"Google");
if (CommonData.currentUser != null)
Firebase.Analytics.FirebaseAnalytics.SetUserId(CommonData.currentUser.data.id);
}

Flutter log event with google analytics

I have set up Google Analytics with in my flutter app. It all seems to be working as standard, with data coming through and being displayed on the analytics console screen, showing users, events count that sort of thing.
I see the default events are: user_engagement, screen_view, session_start, first_open, app_remove, app_clear_data.
These are all having event count data coming through fine. I want to set up my own custom event within the flutter app. I have tried this...
_sendAnalyticsEvent() async {
FirebaseAnalytics analytics = FirebaseAnalytics();
await analytics.logEvent(
name: "save_plant",
parameters: <String, dynamic>{
'plant_name': currentPlant.name,
'plant_species': currentPlant.species,
'plant_group': currentPlant.group,
'new_plant': widget.newPlant
},
);
}
... but nothing seems to be coming through on the events. Am I missing something here with doing custom events with a flutter app? I have the google-services.json file correctly in the android app directory.
When You log an event with FirebaseAnalytics, it takes up to 24 hours to get it available in the Events dashboard.
If You want to test "real time" logging, You should try the Debug View (link).
After You set it up for a specific device (there are two easy steps, check it out here), You will see each event only a few seconds after You log it from Your app, in the DebugView section.
Update to 5.0.11, should resolve the issue
firebase_analytics: ^5.0.11

Configure Multiple Firebase Projects Runtime in iOS application and Firebase/Google Analytics

We are starting to migrate from Google Analytics to Firebase Analytics as it is going to be deprecated in a year. We have a need of initializing the firebase project runtime in our iOS application and we are following the steps mentioned here: https://firebase.google.com/docs/projects/multiprojects?authuser=0
Why do we need to initialize the firebase manually and at runtime? The details are in this issue: Switching between different firebase projects (runtime) in one single APK file
I posted that issue when we encountered a similar problem for push notifications on Android because at that time the documentation was not sufficient. It is really good to know that firebase documentation has been updated to reflect how to manually initialize the sdk for various platforms.
Problem: The problem that we are facing today is that once we initialize the SDK manually for say a "secondary" application and we try to use the firebase analytics, it fails with following error:
2018-12-20 17:14:33.526757-0800 App Name[9218:675367] 5.2.0 - [Firebase/Analytics][I-ACS025018] Event not logged. Call +[FIRApp configure]: AppLaunch
Below is the sample piece of code:
FIROptions *firoptions = [[FIROptions alloc] initWithGoogleAppID:#"Actual_GoogleAppId" GCMSenderID:#"Actual_GCMSenderId"];
firoptions.bundleID = #"actual.bundle.id";
firoptions.APIKey = #"actual-api-key";
firoptions.clientID = #"actual.client.id";
firoptions.databaseURL = #"https://actual.url";
firoptions.storageBucket = #"actualapp.appspot.com";
[FIRApp configureWithName:#"testApp" options:firoptions];
if ([FIRApp appNamed:#"testApp"]) {
[FIRAnalytics logEventWithName:#"AppLaunch" parameters:nil];
}
Looking at the error it tells us to use [FIRApp configure] which configures the default application from the GoogleService-Info.plist in the project. But we do not have GoogleService-Info.plist in our project as suggested in https://firebase.google.com/docs/projects/multiprojects?authuser=0.
TL;DR: We are initializing the firebase app manually in our iOS application using the API [FIRApp configureWithName:#"testApp" options:firoptions]; and the Firebase Analytics gives an error asking us to use default [FIRApp configure] which defeats the purpose of manual initialization.
Any help is greatly appreciated.
Firebase Analytics requires the file to be named GoogleService-Info.plist. Note the first paragraph of https://firebase.google.com/docs/projects/multiprojects?authuser=0 recommends differentiating multiple versions of it by putting them in different directories.
More details about FirebaseAnalytics and multiple plist files at https://github.com/firebase/firebase-ios-sdk/issues/230

Firebase Dynamic Links - Can't get Url in android after install app from play store

If I install the app when clicking the dynamic link. All of that information from dynamic should be still available when I open the app for the first time.How can I get that information? It is not working when I use this: getInitialLink() returns Promise<string|null>;
Since, you haven't mentioned - I'm assuming you are having problems with shorter urls, if that's the case try putting the longer url.
Or refer here on Simon's answer: When I use the long instead of short links, everything works perfectly fine.
On Android, you use the getInvitation() method to get data from the Dynamic Link:
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, false).setResultCallback
(/* ... */);
Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:
Firebase Documentation - Use Case
For future reference or detailed answer on Firebase Dynamic Links
Behave just like normal Links
In cases where the application doesn’t require installation (say, if it’s already installed) then clicking the Dynamic Link will automatically open the link to the desired screen.
Dynamic Links have a very simple process flow:
The user begins by clicking the Dynamic Link
If the the needs of the Dynamic Link target are satisfied (this is, the application being installed) then the user is navigated to the target location
Otherwise, if the application requires install in order to navigate
to the Dynamic Link target, the the user is taken to the point of
install for the application. Once the application has been installed,
the user is navigated to the target location of the Dynamic Link
And if that wasn’t all, we can integrate Dynamic Links with Firebase Analytics to track the interaction with any links that we generate for our applications. But if we only require simple tracking, then we can use the automatic built-in analytics from the Dynamic Links panel within the Firebase Console where we can also obtain attribution and referrer information for interacted links with no extra effort required from our side.
What makes it different from Google Analytics?
One of the first things that came to my mind when I read about Firebase Analytics was, “What about my Google Analytics setup?”. So if you already have Google Analytics in place, then why would you make the switch to Firebase Analytics? Well, here’s a couple of differences between the two:
Audiences
We can use Firebase Analytics to create Audiences — these are groups of users that we can then interact with using other Firebase service such as Firebase Notifications and / or Firebase Remote Config.
Integration with other Firebase Services
An awesome thing with Firebase Analytics is that we can integrate other Firebase services with analytics. For example, creating an Audience of users who have experienced a crash reported through Firebase Crash Reporting.
Lower Method Count
The Google Analytics dependency on Android has a total count of 18,607 methods and has a total of 4kb used for dependancies. On the other hand, Firebase Core (for Analytics) has a method count of 15,130 and only 1kb used for dependancies.
Automatic Tracking
When we add the firebase core dependency, it will automatically begin tracking a collection of user engagement events and device information for us — this is useful if you’re looking to only collect the minimal data for your app.
Unlimited Reporting
For up to 500 events, Firebase Analytics provides us with unlimited reporting straight out of the box for free!
No Singleton Initialisation
When setting up Google Analytics on Android we are required to initialize a Singleton instance. Firebase Analytics are simply available by fetching the instance directly from where we wish to track data. This isn’t much effort obviously but just makes the setup flow slightly easier.
Single Console
All of the data for every Firebase service is available for a single console. That makes it both easier and quicker for us to navigate from checking the analytic stats for our app to viewing the latest crash reports.
It looks like this is a react-native-firebase open bug for android
For fix the only thing that is required to be changed in module code:
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null;
}
to
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData);
if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) {
return true;
}
return false;
}
Bug reference : https://github.com/invertase/react-native-firebase/issues/1273
Please Check Your Manifest file
open AndroidManifest.file => In your activity tag there is intent-filter tag put below line in that tag.
<data android:scheme="https" android:host="your.dynamic.link" />
<data android:scheme="http" android:host="your.dynamic.link" />
If already done then check this link for the full blog on the dynamic link with react native.
Link: http://blog.logicwind.com/react-native-dynamic-links-using-firebase/
I hope this will help. sorry for the typos.

Google Cloud Messaging not working with Phonegap

I'm having a lot of trouble to get Google Cloud Messaging to work in my Phonegap-based app.
I'm following the instructions that are here.
It uses the PushPlugin, which I installed in my app according to the instructions.
Somehow I get no response after registering, nothing happens (no console.log appears) when I do :
window.plugins.pushNotification.register(
pushSuccessHandler,
pushErrorHandler, {
"senderID":"12345678",
"ecb":"onNotificationGCM"
}
);
var pushSuccessHandler = function(result) {
console.log(result);
};
var pushErrorHandler = function(error) {
console.log(error);
};
var onNotificationGCM = function(e) {
console.log(e);
switch(e.event) {
case 'registered' : {
console.log('android reg id: ' + e.regid);
break;
}
}
};
I setup an API project in Google Developer Console, got a project number that I used as the SenderID, and did all modifications to the Phonegap manifest and config xml files.
My app is not published yet in the Play store.
Is this necessary to get Cloud Messaging working?
And is the code above enough to get a 'reg id', or do I first need to push something from the server, but with what 'reg id' then??
Somewhere I read that the push notifications only work in a Phonegap-app when it is running, or when the notification is clicked, so not when the app is started from the normal icon. I don't understand this however, because aren't the notifications supposed to work when the app is not running?
Push notification will work without publishing, publishing is not required.
Only you have to get Sender ID from developer console.
Sender Id - its project number in developer console
for more detail you can check here
https://github.com/phonegap-build/PushPlugin
I am using it its woreking fine for both android and iOS
Update:
I'm using Intellij IDEA to build the app. When I compiled with phonegap build android the push notifications were working ok.
I had to add the 'android-support-v13.jar' and 'gcm.jar' files as a library in the Project Settings of the IDEA project, to get it working. These libraries need to be added to the Dependencies of the main module with scope 'Compile'.
Before I only added them directly in Dependencies of the module, with Scope 'Provided' but apparently that doesn't work (although it compiled).

Categories

Resources