Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ionic-service-common
ionic-service-core
====================

Common required service tools and addons
10 changes: 8 additions & 2 deletions ionic-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function($q, $timeout, $http, persistentStorage, $ionicApp) {

var storageKeyName = 'ionic_analytics_user_' + $ionicApp.getApp().app_id,
user = persistentStorage.retrieveObject(storageKeyName) || {},
deviceCordova = ionic.Platform.device(),
deviceCordova = window.device || {},
device = {
screen_width: window.innerWidth * (window.devicePixelRatio || 1),
screen_height: window.innerHeight * (window.devicePixelRatio || 1)
Expand All @@ -312,9 +312,10 @@ function($q, $timeout, $http, persistentStorage, $ionicApp) {
if (deviceCordova.version) device.version = deviceCordova.version;
if (deviceCordova.uuid) device.uuid = deviceCordova.uuid;


// Flag if we've changed anything on our user
var dirty = false;
dirty = storeOrDirty('is_on_device', ionic.Platform.isWebView());
dirty = storeOrDirty('is_on_device', isWebView());
dirty = storeOrDirty('device', device);
if (!user._id) {
user._id = generateGuid();
Expand All @@ -325,6 +326,11 @@ function($q, $timeout, $http, persistentStorage, $ionicApp) {
persistentStorage.storeObject(storageKeyName, user);
}

function isWebView() {
// using logic from ionic.Platform.isWebView()
return !(!window.cordova && !window.PhoneGap && !window.phonegap && !window.forge);
}

function generateGuid() {
// Some crazy bit-twiddling to generate a random guid
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
Expand Down