diff --git a/examples/mini-program-example/src/pages/api/openAPIS/subscribeNews/index.tsx b/examples/mini-program-example/src/pages/api/openAPIS/subscribeNews/index.tsx index b63752133e6c..28dbbfeb122d 100644 --- a/examples/mini-program-example/src/pages/api/openAPIS/subscribeNews/index.tsx +++ b/examples/mini-program-example/src/pages/api/openAPIS/subscribeNews/index.tsx @@ -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) => { diff --git a/packages/taro-mpharmony/src/api/media/live/LivePlayerContext.ts b/packages/taro-mpharmony/src/api/media/live/LivePlayerContext.ts index 18a2a673f49d..f2a077575928 100644 --- a/packages/taro-mpharmony/src/api/media/live/LivePlayerContext.ts +++ b/packages/taro-mpharmony/src/api/media/live/LivePlayerContext.ts @@ -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.') } diff --git a/packages/taro-mpharmony/src/api/open-api/settings/getSetting.ts b/packages/taro-mpharmony/src/api/open-api/settings/getSetting.ts index 526d32ba2cad..e5e4c34805ef 100644 --- a/packages/taro-mpharmony/src/api/open-api/settings/getSetting.ts +++ b/packages/taro-mpharmony/src/api/open-api/settings/getSetting.ts @@ -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) diff --git a/packages/taro-mpharmony/src/api/open-api/settings/openSetting.ts b/packages/taro-mpharmony/src/api/open-api/settings/openSetting.ts index b9bbb09b2044..ff8b23b1e79a 100644 --- a/packages/taro-mpharmony/src/api/open-api/settings/openSetting.ts +++ b/packages/taro-mpharmony/src/api/open-api/settings/openSetting.ts @@ -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) diff --git a/packages/taro-mpharmony/src/api/open-api/subscribe-message.ts b/packages/taro-mpharmony/src/api/open-api/subscribe-message.ts index a6a1bc872044..0072461cdc9c 100644 --- a/packages/taro-mpharmony/src/api/open-api/subscribe-message.ts +++ b/packages/taro-mpharmony/src/api/open-api/subscribe-message.ts @@ -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) + } +} /** * 订阅设备消息接口,调用后弹出授权框,用户同意后会允许开发者给用户发送订阅模版消息 diff --git a/packages/taro-platform-mpharmony/build/config/harmony-definition.json b/packages/taro-platform-mpharmony/build/config/harmony-definition.json index 5d80dc63fa89..831d5f4905e8 100644 --- a/packages/taro-platform-mpharmony/build/config/harmony-definition.json +++ b/packages/taro-platform-mpharmony/build/config/harmony-definition.json @@ -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,