Hybrid Mobile Apps Installation

Heap can be implemented on Hybrid Mobile Frameworks (Capacitor, Cordova, Ionic) if certain requirements are met. Hybrid Mobile Frameworks leverage WebViews to load web content through embedded browser functionality. In order to track user behavior in these apps, you will have to follow the Heap Web Installation instructions. Heap's Web SDK (heap.js) requires cookies to be set. Some versions of Hybrid Frameworks do support cookies and will be compatible with Heap's Web SDK without additional work. For those frameworks that don't natively support cookies, you will need to use a cookie manager.

Cordova can be configured to support Heap with some slight modifications. For example, on Android, add this line within /android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:

CookieManager.setAcceptFileSchemeCookies(true);

To work, setAcceptFileSchemeCookies(true) has to be run before CookieManager is instantiated. For example:

public SystemCookieManager(WebView webview) {
            webView = webview;
            CookieManager.setAcceptFileSchemeCookies(true);
            cookieManager = CookieManager.getInstance();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                cookieManager.setAcceptThirdPartyCookies(webView, true);
            }
        }

If you use Crosswalk, Cordova and Ionic will work on Android if you add this line within platforms/android/src/org/crosswalk/engine/XWalkCordovaCookieManager.java:

public XWalkCordovaCookieManager() {
            cookieManager = new XWalkCookieManager();      ///forces file cookies
            cookieManager.setAcceptFileSchemeCookies(true);
            }