NgRx store runtime check NgZone failing on android - ngrx

We implemented a network check as a side effect with window event online and offline.
online$ = createEffect(() => {
return fromEvent(window, 'online').pipe(mapTo(NetworkActions.deviceOnline()));
});
This works fine in Desktop Chrome and on iOS Safari but somehow results in a strictActionWithinNgZone runtime check on Android:
{
"state": {
"keyboard": {
"isKeyboardOpen": false
},
"network": {
"isDeviceOnline": true
}
},
"error": "Error: Action '[Network] Device Online' running outside NgZone. https://ngrx.io/guide/store/configuration/runtime-checks#strictactionwithinngzone"
},
Does anybody have any idea why this only happens in Android and why it even is a problem to begin with?
Edit:
As far as I understand it, fromEvent(window, '...') should always be inside the zone because zone.js does patch all Browser EventTarget.
Also this is on an Ionic + Cordova App but only when built on Android. Only reason I could see for the difference could be in the Webview it is running in but other than that it is just basic RxJS and Angular
Thanks Pascal

It looks like this was a super specific problem with an Ionic + Cordova App and the Cordova Network Plugin https://ionicframework.com/docs/native/network
This seems to interfere with the Android Platform. Without the Plugins the Error does not occur but the online and offline window events also never fire on Android. So I guess this has nothing to do with NgRx.

Related

firebase.notifications().getInitialNotification() returns null in iOS

I have a React Native project and I'm using Firebase, thus using react-native-firebase npm package in my project to be able to handle push notifications. I followed the docs here. All seems fine so far except that getInitialNotification() function which keeps giving me null in iOS. Therefore, I can't check if the app is opened by notification tap. Everything works like a charm in Android though.
Any suggestions?
async componentDidMount() {
const notificationOpen: NotificationOpen = await firebase.notifications().getInitialNotification();
console.log(notificationOpen); // Outputs null
}
SOLVED
I solved the issue by using latest react-native (0.59.9 > 0.60.5) and react-native-firebase (5.5.4 > 5.5.6) versions.

Ionic only works with ionic run android

I have a weird issue with my ionic app, it only works when i run with : 'ionic run android' from my computer (testing) to my mobile. but when i want to run the app from my mobile it dont loads the database (i was using sqlite)
I put my code on onDeviceReady(), it is wrong? (im working without angular, only js and cordova):
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
//console.log('onload');
}
// device APIs are available
//
function onDeviceReady() {
//my main code
}
please, can you help me?

Meteor, Accounts.callLoginMethod() doesn't call custom login handler on mobile device

My code works as expected in desktop browser and on android emulator but it doesn't work on android device (debug mode via USB).
I've registered custom login handler in server code
Accounts.registerLoginHandler("customLoginHandler", function (options) {
console.log("customLoginHandler()");
});
Then on specific UI event I'm calling it from client code
console.log("calling custom login");
Accounts.callLoginMethod({
methodArguments: [ {clientUser: "hello", clientPassword: "world"} ],
userCallback: function() {
console.log("clientCustomLogin callback");
}
});
console.log("done");
Console output when running this code on desktop or android emulator
customLoginHandler()
on mobile
calling custom login
done
whole client code is located inside
if (Meteor.isClient) {
block. Why the output is so different?
Meteor version 1.1.0.2, server OS - Linux, mobile - Android 4.4.2
Meteor is started by the command:
meteor run android-device
Packages installed:
$ meteor list
accounts-base 1.2.0 A user account system
http 1.1.0 Make HTTP calls to remote servers
meteor-platform 1.2.2 Include a standard set of Meteor packages in your app
twbs:bootstrap 3.3.4 The most popular front-end framework for developing responsive, mobile first projects on the web.
Short answer: remove the app on android, then run meteor run android-device
Long asnwer.
I don't know why it is possible, but It looks like the app was not fully updated (or not updated at all starting from some point) on the mobile device.
I was playing with accounts-base, accounts-password and accounts-ui packages reinstallation, but then I noticed that when I replaced my template with standard {{> loginButtons}} (in main html file) nothing has changed on mobile after meteor rerunning and the application refreshing on android.
Then I just removed the app from android and started meteor again.
After that the applicated started to work as expected.

Why Visual Studio Cordova project always resumes while debugging for parenthesis in index.js

I've just created a vs-cordova application. When I ripple this application on chrome browser everything works as expected.
BUT,
The debugger breaks on end of cordova.js and index.js. The index.js is below. Break point hits the final bold area. But why? I do not see anything in output area.I opened CLR errors by CTRL+Alt+E ,but didn't help either. I do not see any error on js-output as well. The function is anonymous has no name.So the final parentheses seems fine, isn't it?
Now,I just hit F5 and continue.It's cool but I found this a bit annoying for a while! Especially for android target.It breaks the code for many places. Have you got any suggestion for me ?
BTW, as far as I noticed debugger firstly stops for cordova.js which is added into project when I start debugging then finds index.js.
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
};
function onPause() {
// TODO: This application has been suspended. Save application state here.
};
function onResume() {
// TODO: This application has been reactivated. Restore application state here.
};
} )();
This is due to an issue in our web debugging code that surfaced after a recent update to Chrome. It has been fixed in VS 2015 CTP6 that was made available recently. It will also be fixed in our next extension update to VS2013.

How do you see logging from a Meteor Cordova iOS app?

From what I understand, doing a console.log in a normal Cordova app gets piped to the Xcode debug output, but that doesn't work for my Meteor Cordova iOS app, so I've been doing alerts, which isn't as good.
#Ethaan's answer is a good point, but I don't think it is answering the OP's intended question. I am going to re-iterate the comment from #user728291 on the Question since I believe it is the sought answer.
Safari Remote Debugging will show you console.log messages from
Xcode's simulator or a connected device.
And in the case that the hyper-link may someday be moot, I will re-iterate the referenced text from the link:
If you are doing iOS PhoneGap debugging and have the Safari Develop Menu enabled, you can access the currently active session through the built-in Safari Web Inspector. To activate, go to Develop -> (iPad || iPhone) Simulator (normally, the third menu item) and click the active session you want to connect to. Voila!
The same way you can use Meteor.isServer and Meteor.isClient booleans
to separate your client-side code and server-side code, you can use
Meteor.isCordova constant to separate your Cordova/Phonegap-specific
code from the rest of code shipped to browsers and mobile devices.
From Meteor Cordova Phonegap Integration Documentation
So try with this.
if (Meteor.isCordova) {
console.log('Hi iam on the console from Xcode")
console.log("Welcome back " + Meteor.user().username);
console.log("the user with the id " + Meteor.userId() + " Just logged In");
}

Resources