Search code examples
iosfirebasetitaniumappceleratortitanium-modules

Firebase analytics with latest Ti SDK 9.0.3 GA having issue for screen_view


I tried using Firebase with previous version of Ti SDK (7.5.2). Where both FIRAnalytics.setScreenName and FIRAnalytics.logEventWithName (methods of ti.firebase, equality method in other modules) working fine.

Initial thought was, may be module problem. But reading few blog posts understand Firebase will track screen views automatically https://firebase.google.com/docs/analytics/screenviews .

Of-course we can also call manually.

If my guess is right, on app launch firebase started tracking screen time and we are getting below error. (I tried with ti.firebase, firebase.analytics and own sample native mobile for ios)

objc[67740]: Cannot form weak reference to instance (0x7f9ab8e0aac0) of class UIViewController. It is possible that this object was over-released, or is in the process of deallocation.

I found an alternative to turn off screen tracking. By adding FirebaseScreenReportingEnabled to false in Project's info.plist. For Titanium project we need to add in tiapp.xml . And This time we did not see any issue and log event is working fine. But I did not see any screen views, even manual. Because this option will totally block screen trackings.

:
<ios>
        <enable-launch-screen-storyboard>true</enable-launch-screen-storyboard>
        <use-app-thinning>true</use-app-thinning>
        <plist>
            <dict>
                :
                <key>UIStatusBarStyle</key>
                <string>UIStatusBarStyleDefault</string>
                <key>FirebaseScreenReportingEnabled</key>
                <false/>
            </dict>
        </plist>
    </ios>
:

But this even not tracking manually screen views. So we are losing a track of avg screen time.

Here the example of ti.firebase (I tried with firebase.analytics unfortunately I can refer the sample code here, but we can use this https://github.com/hansemannn/titanium-firebase-analytics/blob/master/example/app.js)

var _tFireb = require('ti.firebase');
_tFireb.configure();

function doClick(e) {
    alert($.label.text);
    
    var logParams = {
        'name': "button_clicked",
        'parameters': null
    };
    //Ti.API.info("Sending logEvtData", logParams);
    _tFireb.FIRAnalytics.logEventWithName(logParams);
}

$.index.open();

_tFireb.FIRAnalytics.setScreenName({
        'screenName' :  "indexdefault",
        'screenClass' : "indexdefault"
    });

Solution

  • We tried with latest titanium-firebase-analytics module. It is working fine.

    https://github.com/hansemannn/titanium-firebase-analytics/releases/tag/ios-2.0.0

    There is change in Firebase itself. Now sending Screenview also same like log event by passing constant. Note: if you pass "screen_view" it will not work. you need to use const like below, module is already taken care of it.

    [FIRAnalytics logEventWithName:kFIREventScreenView parameters:]