Skip to content

Commit

Permalink
Merge pull request handsomeliuyang#451 from wangzhenhuiOne/release-3.…
Browse files Browse the repository at this point in the history
…6.8-app

feat: 新增功能订阅消息
  • Loading branch information
szzwk authored Dec 4, 2023
2 parents 57ca80b + 6dce2ae commit a7dae4e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ export default class Index extends React.Component {
{
id: 'requestSubscribeMessage',
inputData: {
tmplIds: [''],
tmplIds: ['OTHER_TYPES','CONTENT_INFORMATION','SERVICE_INFORMATION','SOCIAL_COMMUNICATION'],
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.requestSubscribeMessage')
Taro.requestSubscribeMessage(data).then((res) => {
TestConsole.consoleNormal('requestSubscribeMessage', res)
})
Taro.requestSubscribeMessage({
...data,
success: (res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ export class LivePlayerContext implements Taro.LivePlayerContext {
this.LivePlayer._snapshot(_option)
.then((result) => {
_option?.success?.(result)
_option?.complete?.(result)
})
.catch((err) => {
_option?.fail?.(err)
})
.finally(() => {
_option?.complete?.({ errMsg: `ok` })
_option?.complete?.(err)
})
}


startCasting (_option?: Taro.LivePlayerContext.StartCastingOption | undefined): void {
throw new Error('Method not implemented.')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const getSetting: typeof Taro.getSetting = function (options) {
(res: any) => {
const result: Taro.getSetting.SuccessCallbackResult = {
authSetting: res.authSetting,
subscriptionsSetting: res.subscriptionsSetting,
miniprogramAuthSetting: res.miniprogramAuthSetting,
subscriptionsSetting: res.subscriptionsSetting || {},
miniprogramAuthSetting: {},
errMsg: res.errMsg,
}
handle.success(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const openSetting: typeof Taro.openSetting = function (options) {
const result: Taro.openSetting.SuccessCallbackResult = {

authSetting: res.authSetting,
subscriptionsSetting: res.subscriptionsSetting,
subscriptionsSetting: res.subscriptionsSetting || {},
errMsg: res.errMsg,
}
handle.success(result)
Expand Down
42 changes: 37 additions & 5 deletions packages/taro-mpharmony/src/api/open-api/subscribe-message.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
import Taro from '@tarojs/taro'

/**
* 请求订阅消息
*
* @canUse requestSubscribeMessage
* @null_implementation
* @__object [tmplIds]
* @__success [errMsg, TEMPLATE_ID]
*/
export const requestSubscribeMessage = () =>
Promise.resolve({
errMsg: 'requestSubscribeMessage:ok',
})
export const requestSubscribeMessage = (options) => {
const tmplIds = options.tmplIds
try {
// @ts-ignore
native.requestSubscribeMessage(options).then((res) => {
if (res.errMsg === 'success') {
const tmpItem = {}
tmplIds.forEach(item => {
tmpItem[item] = 'accept'
})
const result:Taro.requestSubscribeMessage.SuccessCallbackResult = {
errMsg: 'requestSubscribeMessage: ok',
...tmpItem
}
options.success?.(result)
options.complete?.(result)
} else {
const result:Taro.requestSubscribeMessage.FailCallbackResult = {
...res
}
options.fail?.(result)
options.complete?.(result)
}
})
} catch (res) {
const result:Taro.requestSubscribeMessage.FailCallbackResult = {
errCode: 500,
errMsg: JSON.stringify(res)
}
options.fail?.(result)
options.complete?.(result)
}
}

/**
* 订阅设备消息接口,调用后弹出授权框,用户同意后会允许开发者给用户发送订阅模版消息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,14 @@
"requestOrderPayment": false,
"requestPayment": true,
"requestSubscribeDeviceMessage": false,
"requestSubscribeMessage": true,
"requestSubscribeMessage": {
"object": {
"tmplIds": true
},
"success": {
"errMsg": true
}
},
"requirePrivacyAuthorize": false,
"reserveChannelsLive": false,
"revokeBufferURL": false,
Expand Down

0 comments on commit a7dae4e

Please sign in to comment.