API Documentation for MagLoft Mobile Apps HPUB2 JavaScript Context
npm install hpub2
</body>
tagwindow.MagloftApi
window.MagloftApi.context
MagloftApi.openUrl({ url: 'https://www.magloft.com/', target: '_blank' })
MagloftApi.trackEvent({ name: 'purchase', parameters: { sku: 'ML123', price: 99 } })
MagloftApi.toggleNavigator({ active: true })
MagloftApi.shareUrl({ url: 'https://www.magloft.com/' })
MagloftApi.shareIssue()
MagloftApi.close()
This will trigger the native Login Dialog. Will return the logged in
reader
(if successful), orundefined
(if failed)
MagloftApi.login().then((reader) => {
alert(reader.email)
})
This will trigger the native Push Notification screen, prompting users to either allow or block notifications. Will return the new pushToken (if allowed), or
undefined
(if blocked)
MagloftApi.requestPushPermissions().then((pushToken) => {
alert(pushToken)
})
Schedule up to 1000 messages for the current user. The user needs to be logged in and must have accepted push notification permissions.
MagloftApi.schedulePushMessages([{
title: 'Message 1',
body: 'Message Body'
deliveryDate: 1663910000, // UNIX Timestamp
data: { key: 'value' } // Any Record<string, string>
}, {
title: 'Message 2',
body: 'Message Body'
deliveryDate: 1663910000, // UNIX Timestamp
data: { key: 'value' } // Any Record<string, string>
}]).then((scheduledCount) => {
alert(`Scheduled ${scheduledCount} messages`)
})
Clear all scheduled push messages for the current user. The user needs to be logged in and must have accepted push notification permissions.
MagloftApi.clearPushMessages().then(() => {
alert(`Cleared all push messages`)
})
Generated using TypeDoc