# wx.miniapp.getXGPushManager

This ability encapsulatesTencent Cloud Mobile PushService implementation, the specific access process can be viewedMessage Push Dxplaination Document

# getXGPushManager

Gets the verbose management object (singleton).

# case


const xgpushMgr  = wx.miniapp.getXGPushManager()

# registerPush

Enable message push capability. After successful implementation, it will success Callback device token(Android and iOS Data structure is different), in order to push messages to the device.

# parameter

attribute type Default value Required Introductions
success function - no Registration is successful, the parameter is device information Attention! iOS Android's callback parameters are different
fail function - no Registration failure

# case

const xgpushMgr  = wx.miniapp.getXGPushManager()
xgpushMgr.registerPush ({
    success(args) {
        // Attention! iOS Android's callback parameters are different
        console.log('registerPush', args)
    },
    fail(e) {
        console.error(e)
    }
})

# unregisterPush

Untap the feed.

# case

const xgpushMgr  = wx.miniapp.getXGPushManager()
xgpushMgr.unregisterPush()

# onNotificationClickedResult

Listen Listen to the message callback that the user clicks

# parameter

type Default value Required Introductions
function yes Monitoring method

# case

const onTPNSClickResult = (result) => {
    console.log('onTPNSClickResult')
}
const xgpushMgr  = wx.miniapp.getXGPushManager()
xgpushMgr.onNotificationClickedResult(onTPNSClickResult)

# offNotificationClickedResult

Cancel the message callback that listens for user clicks

# parameter

type Default value Required Introductions
function yes Monitoring method

# case

const onTPNSClickResult = (result) => {
    console.log('onTPNSClickResult')
}
const xgpushMgr  = wx.miniapp.getXGPushManager()
xgpushMgr.offNotificationClickedResult(onTPNSClickResult)

# setBadge

Set to apply local corner markers. Effective only in iOS.

# parameter

attribute type Required Introductions
number integer yes Hornmark number
success function no Setup Success
fail function no Setting failure

# case

const xgpushMgr  = wx.miniapp.getXGPushManager()
xgpushMgr.setBadge({
    number: -1,
    success() {
        console.log('xgpushSetBadge success')
    },
    fail(e) {
        console.error('xgpushSetBadge failed', e)
    }
})

# onXgPushLog

Get a log of the message push

Support only iOS

# case

const xgpushMgr  = wx.miniapp.getXGPushManager()
const xgpushLog = (log) => {
    console.log(log)
}
// Register to listen
xgpushMgr.onXgPushLog (xgpushLog)

# offXgPushLog

Unlog getting push messages

Support only iOS

# case

const xgpushMgr  = wx.miniapp.getXGPushManager()
const xgpushLog = (log) => {
    console.log(log)
}
// registered
xgpushMgr.offXgPushLog (xgpushLog)