本文整理匯總了TypeScript中@ionic-native/network.Network.onConnect方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Network.onConnect方法的具體用法?TypeScript Network.onConnect怎麽用?TypeScript Network.onConnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ionic-native/network.Network
的用法示例。
在下文中一共展示了Network.onConnect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: watchOnline
watchOnline(): any {
return this.network.onConnect();
}
示例2: constructor
constructor(mainMenuDelegate: CoreMainMenuDelegate, mainmenuHandler: AddonMessagesMainMenuHandler,
contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: AddonMessagesIndexLinkHandler,
discussionLinkHandler: AddonMessagesDiscussionLinkHandler, sendMessageHandler: AddonMessagesSendMessageUserHandler,
userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler,
network: Network, zone: NgZone, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider,
localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
pushNotificationsDelegate: AddonPushNotificationsDelegate, utils: CoreUtilsProvider,
addContactHandler: AddonMessagesAddContactUserHandler, blockContactHandler: AddonMessagesBlockContactUserHandler) {
// Register handlers.
mainMenuDelegate.registerHandler(mainmenuHandler);
contentLinksDelegate.registerHandler(indexLinkHandler);
contentLinksDelegate.registerHandler(discussionLinkHandler);
userDelegate.registerHandler(sendMessageHandler);
userDelegate.registerHandler(addContactHandler);
userDelegate.registerHandler(blockContactHandler);
cronDelegate.register(syncHandler);
cronDelegate.register(mainmenuHandler);
settingsDelegate.registerHandler(settingsHandler);
// Sync some discussions when device goes online.
network.onConnect().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
zone.run(() => {
messagesSync.syncAllDiscussions(undefined, true);
});
});
const notificationClicked = (notification: any): void => {
messagesProvider.isMessagingEnabledForSite(notification.site).then(() => {
sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages', notification.site).then((disabled) => {
if (disabled) {
// Messages are disabled, stop.
return;
}
messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
linkHelper.goInSite(undefined, 'AddonMessagesIndexPage', undefined, notification.site);
});
});
});
};
if (appProvider.isDesktop()) {
// Listen for clicks in simulated push notifications.
localNotifications.registerClick(AddonMessagesProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
}
// Register push notification clicks.
pushNotificationsDelegate.on('click').subscribe((notification) => {
if (utils.isFalseOrZero(notification.notif)) {
notificationClicked(notification);
return true;
}
});
// Allow migrating the table from the old app to the new schema.
updateManager.registerSiteTableMigration({
name: 'mma_messages_offline_messages',
newName: AddonMessagesOfflineProvider.MESSAGES_TABLE,
fields: [
{
name: 'textformat',
delete: true
}
]
});
// Migrate the component name.
updateManager.registerLocalNotifComponentMigration('mmaMessagesPushSimulation',
AddonMessagesProvider.PUSH_SIMULATION_COMPONENT);
}