Metamask mobile browser not injecting window.ethereum - metamask

I'm having an issue where Metamask's mobile browser simply isn't injecting window.ethereum at all into my website. This is extra confusing since I'm doing everything the same way I did in a previous website that worked fine.
if (window.ethereum) {
this.handleEthereum();
} else {
window.addEventListener('ethereum#initialized', this.handleEthereum, {
once: true,
});
}
To confirm that window.ethereum is never injected I also just output it on the screen and it's stays undefined indefinitely.
Everything works completely fine using a desktop browser of course. It's only an issue with metamask's mobile browser.

Related

NativeScript push notifications permission dialog shows behind app

Do you know what could be causing the permissions request dialog on iOS to show behind the app? It actually flashes quickly and then goes behind. I have to press the home button to bring it to the front. Until then the UI is blocked.
I am using Everlive and I am calling the register method in the app's launchEvent as such:
var pushSettings = {
//iOS - specific settings
iOS: {
badge: true,
sound: true,
alert: true,
clearBadge: true
},
notificationCallbackIOS: function (userInfo) {
...
},
//Android - specific settings
android: {
projectNumber: '944301213976'
},
notificationCallbackAndroid: function callback(data) {
...
}
}
el.push.register(pushSettings, function (data) {
...
}, function (error) {
});
Thank you.
EDIT: I should add that I am testing on iOS 9.3.4 and right before the dialog goes behind the app, I get the following warning in the console: enabledRemoteNotificationTypes is not supported in iOS 8.0 and later. Not sure if it matters, but I wanted to mention it, just in case.
So, it turns out that it was a timing issue. I was running the code when the app was initializing. The popup will get displayed, but shortly after, the first screen (login in my case) gets initialized, stealing the focus from the popup.
Once I moved the code in a button tap event (after the screen loading was completed) everything worked as expected.
I am not sure if this is the best way to handle this. I am open for suggestions.
Also, you can see https://github.com/NativeScript/push-plugin/issues/38 for more info. Thank you Anton Dobrev for pointing me to the right direction.

Protractor - Firefox not reloading pages on browser.get(url)

I'm writing some Protractor tests, but I'm running into trouble. When running the tests on Chrome, my tests all pass. When I run the tests on Firefox though, I see that the page is not re-loading between tests. (This messes up the state of the page and causes tests to fail.)
A workaround I'm using right now is to refresh after I 'get' the page, but this is dumb.
Here's my beforeEach:
beforeEach(function() {
ptor = protractor.getInstance();
ptor.ignoreSynchronization = true;
browser.get('#/page');
// I need this to get my Firefox tests to work
browser.navigate().refresh();
});
What can I do to handle this better?
If I have to refresh the page each time, is there a clause like if(firefox) I can use?
I'm running Chrome 34.0.1847 (Mac OS X 10.9.1) successfully, and Firefox 28.0.0 (Mac OS X 10.9) is giving me trouble.
With synchronization off, all protractor does on a browser.get(url) is driver.get(destination);, so it's entirely up to the browser to determine how it wants to load the url.
On the other hand, with synchronization on, protractor first loads a blank page before renavigating to the intended url.
In addition, for firefox, reloading the same angular url on localhost does not reload the page, whereas it does for chrome. Try it: go to an angular app on localhost, enter something in and load the url again. For chrome, this will clear what you entered, but for firefox, it will not.
Turn on synchronization like #AndresD said if your app is Angular

Instanciate Firebreath plugin via JS in IE8

I'm trying to instanciate a plugin made with Firebreath in Internet Explorer 8 but with no luck so far. This is the code that I'm using:
try
{
if(window.ActiveXObject)
{
var plugin = new ActiveXObject("my.plugin");
return true;
}
else
return false;
}
catch(e)
{
return false;
}
This works fine if I put this code in a html page and then open it from disk (also published in my local IIS); but as soon I publish it (it's a facebook application, so, running inside an IFRAME) I get this message (from the catch exception):
Automation server can't create object
I've tried messing around with IE security zones, but nothing happens, always the same message. Is there any workaround for this? I need to be able to get the plugin version (coded inside the plugin).
Thank you!

History issue combining WP7.5, phonegap and jqm

I have a phonegap app that uses jqm that works fine in android and ios.
Porting to WP7 i have an issue with the history, specifically history.back() (but also .go(-1) etc). This refers to going back in history where the previous 'page' was in the same physical html file, just a different data-role=page div.
using a jwm site in a regular browser is fine (with separate 'pages' in the same html file). Also, using history.back() when we go from one html file to another in the app is fine. It's the specific combination of WP7.5, jqm and PG.
Has anyone come across a solution for this? it's driving me crazy, and has been as issue since PG 1.4.1 and jwm 1.0.
EDIT 1: It's possible that the phonegap process of initialising the webview on WP7.5 somehow overrides the jqm history overrides, after they've loaded.
EDIT 2: definitely something to do with jqm not being able to modify the history. each time there is a 'page' change, history.length is still 0.
EDIT 3: When i inspect the 'history' object, i found there is no function for replaceState or pushState - i know jqm uses this for history nav, maybe that's the problem.
ok - this isn't perfect, but here's a solution (read: hack) that works for me. It only works for page hash changes, not actual url changes (but you could add a regex check for that). Put this somewhere in the code that runs on ondeviceready:
if (device.platform == 'WinCE') {
window.history.back = function () {
var p = $.mobile.urlHistory.getPrev();
if (p) {
$.mobile.changePage("#" + p.pageUrl, { reverse: true });
$.mobile.urlHistory.stack.splice(-2, 2);
$.mobile.urlHistory.activeIndex -= 2;
}
}
}

FBJS AJAX.post is not working after permissions dialog

I have problems with facebook application based on flash which communicate with PHP using FBJS-bridge. When someone use the application for the first time, he/she is asked for various permissions. After that, flash contact PHP with ajax but request is never sent. When you refresh page, everything is working without any problems.
If you remove the application on privacy settings, refresh the page and try again - same bug happens. If you allow application, refresh page, in other tab remove application and start application in previous tab - user is asked for permissions but everything is working after allowing application.
This is FBJS code
function openPermissions(){
Facebook.showPermissionDialog(/*permissions string*/, permissionOnDone);
}
function permissionOnDone(perms){
if (!perms) {
document.getElementById("indexswf").callSWF('noallow');
} else {
document.getElementById("indexswf").callSWF('allow');
}
}
function ajaxCall(url,parameters){
var params = {};
for(var i=0;i<parameters.length;i+=2){
params[parameters[i]]=parameters[i+1];
}
ajax = new Ajax();
ajax.requireLogin = true;
ajax.responseType = Ajax.RAW;
ajax.ondone = function(data){
document.getElementById("indexswf").callSWF('parseAjax', data);
}
ajax.post('http://the.url.to/the_real_server/not_to_the_fb_url/'+url,params);
}
openPermissions is called to display permission dialog, and on allow flash function allow() is called. In flash, allow() calls JS function ajaxCall(), which should make ajax request. But, ajax.post never sends request. I know that for sure, because flash function parseAjax was never called and also debugging tools in browsers are not showing any ajax requests. URL and parameters are same as when it is working. No flash or JS errors are detected...
Anyone have idea what is wrong here? Maybe facebook bug again since this was all working few days ago...
ajax.requireLogin = true should be set to false for some reason

Resources