You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Nicolas Loriot (JIRA)" <ji...@apache.org> on 2016/08/01 09:40:20 UTC
[jira] [Commented] (CB-11638) Offline event not triggering
[ https://issues.apache.org/jira/browse/CB-11638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15401772#comment-15401772 ]
Nicolas Loriot commented on CB-11638:
-------------------------------------
Tried on an HTC w/ Android 5.0.2 and no changes, the offline event is not triggered.
I also updated the plugin to 1.2.1, same issue.
Below is my TypeScript code, let me know if anything's wrong.
{code:javascript}
isOnline: boolean = false;
constructor(platform: Platform) {
platform.ready().then(() => {
document.addEventListener('offline', this.onNetworkDisconnect, false);
document.addEventListener('online', this.onNetworkConnect, false);
})
}
private onNetworkDisconnect(): void {
this.isOnline = false;
console.log('Connection lost!', this.isOnline, Network.connection);
}
private onNetworkConnect(): void {
setTimeout(function() {
this.isOnline = Network.connection != Connection.NONE;
console.log('Connection restored!', this.isOnline, Network.connection);
}, 2000);
}
{code}
Thanks.
> Offline event not triggering
> ----------------------------
>
> Key: CB-11638
> URL: https://issues.apache.org/jira/browse/CB-11638
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin Network Information
> Affects Versions: 1.2.0
> Environment: Android 6.0.1, Ionic 2
> Reporter: Nicolas Loriot
>
> The online event is working but i can't get the offline event to fire after enabling airplane mode.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org