Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 新增功能订阅消息 #451

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading