Flurry analytics on Firefox OS privileged app - javascript

I have a Firefox OS app that makes calls to cross domain pages and downloads data to display on the app, wich all works fine because I used the systemXHR permission and appended the { mozSystem: true } on every XMLHttpRequest.
Then I attached the Flurry script, made the FlurryAgent calls in the .js of the app and started recieving the info from the events on the Flurry Event Logs when I ran it on the Firefox OS Simulator. When I tried to install my app on a Firefox OS device, the Flurry session never starts and the app never loads.
I don't understand why Flurry works on the simulator and not on the device. I checked a lot of times for the internet connection on the device, wich works fine for the browser and other apps that were already installed. And my app worked fine on the device before I had attached Flurry.
Here is a sample of my code:
HTML:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My App</title>
<link rel="stylesheet" href="js/jquery.mobile-1.3.2.min.css" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
<link rel="stylesheet" href="css/mystyle.css" />
<script src="https://cdn.flurry.com/js/flurry.js"></script>
<script src="js/app.js"></script>
</head>
<body>
.js
$(document).on('pagebeforecreate', '[data-role="page"]', function(){
if ($(this).attr('id')=="splash"){
$.mobile.allowCrossDomainPages = true;
}
});
$(document).on('pageinit', '[data-role="page"]', function(){
console && console.log($(this).attr('id') + " - pageinit!!");
if ($(this).attr('id')=="splash"){
FlurryAgent.startSession("7ZFX9Z4CVT66KJBVP7CF"); //Here is were it crashes
alert("Inicio sesion flurry");
console && console.log($(this).attr('id') + "- Entro al if para el timer");
var timer = window.setTimeout(next, 10000);
}
});
If there is anything else that you need to help me figure out what happens, let me know.
The device I'm using is a Qualcomm model, especifically Peak and has the OS version: Boot2Gecko 1.1.1.0hd-GP

This may be a CSP issue. Have a look at: https://developer.mozilla.org/en-US/Apps/CSP?redirectlocale=en-US&redirectslug=Apps%2FCSP Specifically Remote scripts are banned.

Related

Desktop Notification Not Working in Converse.js 5.0.1

I am setting up a server, the server is a Centos 7 + Apache machine, I downloaded converse.js and called "css" and "js" through the CDN provided by them, where i just did the Download and put inside my folders ( css , js ) but I am trying to use the notification, because sometimes I need to be notified of new messages when I have Browser minimized for example.
I tried using the documentation to put the following option inside Initialize: show_desktop_notifications: true, but it didn't work .
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Chat.Kmk</title>
<noscript><p><img src="//stats.opkode.com/piwik.php?idsite=5" style="border:0;" alt="" /></p></noscript>
<link type="text/css" rel="stylesheet" href="css/converse.min.css" />
<script src="js/libsignal-protocol.min.js"></script>
<script src="js/converse.min.js"></script>
</head>
<body class="converse-fullscreen">
<div id="conversejs-bg"></div>
<script>
converse.initialize({
authentication: 'login',
auto_away: 300,
auto_reconnect: true,
bosh_service_url: 'http://chat.xxx.xxx:7070/http-bind/', // Please use this connection manager only for testing purposes
message_archiving: 'always',
view_mode: 'fullscreen',
allow_contact_removal:false,
allow_contact_requests:false,
show_chat_state_notifications:true,
show_desktop_notifications:true,
show_chat_state_notifications:'online',
notify_all_room_messages:true
});
</script>
</body>
</html>
I minimized the browser, opened another one, sent a message, but no notifications were displayed.
i had this problem too, but in my case the notification worked on some outdated mozilla browsers, i believe chrome only allow if the source is HTTPS, today i can get notification of converse.js in chrome after placing a certificate SSL on Apache.
Thanks.

JavaScript is not working on my computer (chrome, js activated)

I just try to test a very basic program in javascript but on my computer it does not work. It works on other computer but not mine. I'm launching it on chrome which has javascript activated. There is my code:
index.html
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>p5.js</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js">
</script>
<script src="script.js" type="application/javascript;version=1.7"></script>
</head>
<body>
</body>
</html>
script.js
function setup() {
createCanvas(400,400);
background(0);
var x = random(0,200);
rect(x,x,(200-x)*2,(200-x)*2);
}
function draw() {
}
In my folder I have also an asset folder which is empty and my style.css is empty. With this code I am supposed to have a black square on my screen (the canvas) but there is nothing, and when I check the console on chrome nothing is written. Moreover, the first time I launched index.html a file named debug.log appears:
debug.log
[0126/184004.266:ERROR:settings.cc(263)] Settings version is not 1
Why does this script work on other computer but not mine ?
Thanks for helping.
All of your audio your files listed in the JavaScript code MUST be named as HTTPS, not HTTP. And obviously, that means the website(s) you are linking to (including yours) must be secure. That is, you need to have your security certificates, and make sure they are activated. It's a security issue with Chrome. I hope that helps. = -)
You need to call your function:
index.html
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>p5.js</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>
<script src="script.js" type="application/javascript"</script>
</head>
<body>
</body>
</html>
script.js
function setup() {
createCanvas(400,400);
background(0);
var x = random(0,200);
rect(x,x,(200-x)*2,(200-x)*2);
}
function draw() {
}
setup(); // that is a function call
I tested this on Firefox and Chrome and it works. Javascript is interpreted by your browser, it has nothing to do with your computer. If the exact setup above doesn't work for you then check here. If JS is enabled and it still doesn't work then try removing the p5.js script. If that still doesn't fix it then reinstall Chrome (or even better switch to Firefox)
The accepted answer would be correct if you were not using P5.js. But since you are, you should not call the setup() function yourself! Instead, you need to let P5.js do that for you automatically. It might work with this simple example, but you'll have other problems with e.g. draw() not being called 60 times per second. If setup() and draw() are not being called, that means you're not loading the library correctly.
You need to check your developer tools for any errors, both in the JavaScript console and in the network tab.
My guess is that you're accessing your page as a file:// URL, which can have problems. You need to run a local server and access your files that way instead.

IE 11 Permission Denied Javascript

I have created a trivial HTML/JS/Angular page (below) which when first rendered in IE 11, throws a Permission Denied exception. See images of the debugger console below. My IE version is 11.0.9 on Windows 7.
[EDIT] See source below. Meta tag included, but this does not resolve the issue. txs
<!DOCTYPE html>
<html ng-app="ie11bug">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IE 11 Bug</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.js"></script>
</head>
<body>
<div ng-controller="AppController">
Hello {{pageTitle}}
</div>
<script>
var app = angular.module('ie11bug', []).controller('AppController', function($scope) {
$scope.pageTitle = "This will not appear when page is 1first loaded";
});
</script>
</body>
</html>
I have tried various versions of Angular from 1.4 to 1.6, same result. After clearing the cache and loading the page the error occurs. If I then reload, the page successfully renders.
The error always seems to be thrown when the factory method (called from the $exceptionHandler) assigns the $log service into the cache.
I also get Permission denied when simply trying to log to the console
<script>
console.log("hello");
</script>
Any help/ideas would be appreciated.

Phonegap issue with deviceready event

I'm working on a project for a hybrid mobile app. I used ripple during the build fase for testing and debugging. I used phonegap/cordova to build the apk for android, and this went well. Only now it seems like the the deviceready event is not triggered.
On login I use the following javascript code;
document.addEventListener('deviceready', function() {
var email = $('#loginEmail');
var password = $('#loginPassword');
var base_url = $('#loginUrl');
email.val(window.localStorage.getItem('ptu_email'));
password.val(window.localStorage.getItem('ptu_password'));
base_url.val(window.localStorage.getItem('ptu_url'));
console.log(window.localStorage.getItem('ptu_url'));
$('#loginForm').on('submit', function(event) {
event.preventDefault();
$("#loginForm").validate();
company.BaseUrl = base_url.val();
company.LoginWithEmail(email.val(), password.val()).then(function() {
window.location = 'dashboard.html';
}, function(err) {
console.log("Error:");
console.log(err);
});
});
}, false);
This worked fine when using the ripple emulator but not with the apk installed on my galaxy s4. I looked at some other topics here, regarding issues with deviceready event but haven't find a solution yet. Anyone a idea whats going wrong here?
Use this approach.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Device Ready</title>
<script src="cordova.js"></script>
<script>
function onLoad() {
document.addEventListener('deviceready', main, false);
}
</script>
</head>
<body onload="onLoad()">
</body>
<script>
function main(){
}
</script>
</html>

Store data on WP7?

I am trying to store a few KB of data on a windows phone. I am using phonegap and jquery mobile.
So far I worked with jStorage and that worked well on iOS and Android. jStorage tries localStorage, globalStorage and userData behavior. I also tried cookies.
But nothing worked. Any solution to this? Maybe using PhoneGap.exec, again?
I store & read some small amount of data using phonegap & jQm & wp7
Store some data:
window.localStorage.setItem(key, JSON.stringify(value));
Read some data:
JSON.parse(window.localStorage.getItem(key))
Check if you are using the newest jquery.mobile.js from jQm beta page - there was a new release yesterday
Try this
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Open Database</p>
</body>
</html>
Source: docs.phonegap.com

Categories

Resources