提交 d330ca60 编写于 作者: F fangJinliang1

doc update

Signed-off-by: NfangJinliang1 <fangjinliang1@huawei.com>
Change-Id: I8d57308dba5f54f1f420b0f9a7cb9ed148e6291c
Signed-off-by: NfangJinliang1 <fangjinliang1@huawei.com>
上级 edd52ed2
...@@ -433,7 +433,7 @@ export default { ...@@ -433,7 +433,7 @@ export default {
console.log('ServiceAbility want:' + JSON.stringify(want)); console.log('ServiceAbility want:' + JSON.stringify(want));
console.log('ServiceAbility want name:' + want.bundleName) console.log('ServiceAbility want name:' + want.bundleName)
} catch(err) { } catch(err) {
console.log("ServiceAbility error:" + err) console.log('ServiceAbility error:' + err)
} }
console.info('ServiceAbility onConnect end'); console.info('ServiceAbility onConnect end');
return new IdlTestImp('connect'); return new IdlTestImp('connect');
...@@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility';
function callbackTestIntTransaction(result: number, ret: number): void { function callbackTestIntTransaction(result: number, ret: number): void {
if (result == 0 && ret == 124) { if (result == 0 && ret == 124) {
console.log("case 1 success "); console.log('case 1 success');
} }
} }
function callbackTestStringTransaction(result: number): void { function callbackTestStringTransaction(result: number): void {
if (result == 0) { if (result == 0) {
console.log("case 2 success "); console.log('case 2 success');
} }
} }
...@@ -472,17 +472,17 @@ var onAbilityConnectDone = { ...@@ -472,17 +472,17 @@ var onAbilityConnectDone = {
testProxy.testStringTransaction('hello', callbackTestStringTransaction); testProxy.testStringTransaction('hello', callbackTestStringTransaction);
}, },
onDisconnect:function (elementName) { onDisconnect:function (elementName) {
console.log("onDisconnectService onDisconnect"); console.log('onDisconnectService onDisconnect');
}, },
onFailed:function (code) { onFailed:function (code) {
console.log("onDisconnectService onFailed"); console.log('onDisconnectService onFailed');
} }
}; };
function connectAbility: void { function connectAbility: void {
let want = { let want = {
"bundleName":"com.example.myapplicationidl", bundleName: 'com.example.myapplicationidl',
"abilityName": "com.example.myapplicationidl.ServiceAbility" abilityName: 'com.example.myapplicationidl.ServiceAbility'
}; };
let connectionId = -1; let connectionId = -1;
connectionId = featureAbility.connectAbility(want, onAbilityConnectDone); connectionId = featureAbility.connectAbility(want, onAbilityConnectDone);
...@@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { ...@@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel();
_data.writeInt(data); _data.writeInt(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) { this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) {
if (result.errCode === 0) { if (result.errCode == 0) {
let _errCode = result.reply.readInt(); let _errCode = result.reply.readInt();
if (_errCode != 0) { if (_errCode != 0) {
let _returnValue = undefined; let _returnValue = undefined;
...@@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { ...@@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _returnValue = result.reply.readInt(); let _returnValue = result.reply.readInt();
callback(_errCode, _returnValue); callback(_errCode, _returnValue);
} else { } else {
console.log("sendRequest failed, errCode: " + result.errCode); console.log('sendRequest failed, errCode: ' + result.errCode);
} }
}) })
} }
...@@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService { ...@@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel();
_data.writeString(data); _data.writeString(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) { this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) {
if (result.errCode === 0) { if (result.errCode == 0) {
let _errCode = result.reply.readInt(); let _errCode = result.reply.readInt();
callback(_errCode); callback(_errCode);
} else { } else {
console.log("sendRequest failed, errCode: " + result.errCode); console.log('sendRequest failed, errCode: ' + result.errCode);
} }
}) })
} }
...@@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager'; ...@@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager';
function testIntTransactionCallback(errCode: number, returnValue: number) function testIntTransactionCallback(errCode: number, returnValue: number)
{ {
console.log("errCode: " + errCode + " returnValue: " + returnValue); console.log('errCode: ' + errCode + ' returnValue: ' + returnValue);
} }
function testStringTransactionCallback(errCode: number) function testStringTransactionCallback(errCode: number)
{ {
console.log("errCode: " + errCode); console.log('errCode: ' + errCode);
} }
function jsProxyTriggerCppStub() function jsProxyTriggerCppStub()
...@@ -660,6 +660,6 @@ function jsProxyTriggerCppStub() ...@@ -660,6 +660,6 @@ function jsProxyTriggerCppStub()
tsProxy.testIntTransaction(10, testIntTransactionCallback); tsProxy.testIntTransaction(10, testIntTransactionCallback);
// invoke testStringTransaction // invoke testStringTransaction
tsProxy.testStringTransaction("test", testIntTransactionCallback); tsProxy.testStringTransaction('test', testIntTransactionCallback);
} }
``` ```
...@@ -32,7 +32,8 @@ import commonEvent from '@ohos.commonEvent'; ...@@ -32,7 +32,8 @@ import commonEvent from '@ohos.commonEvent';
2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscribeInfo文档](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo)介绍。 2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscribeInfo文档](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo)介绍。
```js ```js
private subscriber = null //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
private subscriber = null
//订阅者信息 //订阅者信息
var subscribeInfo = { var subscribeInfo = {
......
# 公共事件与通知开发概述 # 公共事件与通知开发概述
公共事件与通知提供了应用程序向系统其他应用程序发布消息、接收来自系统或其他应用特定消息的能力,这些消息可以是新闻推送、广告通知或者预警信息。 公共事件与通知提供了应用程序向系统其他应用程序发布消息、接收来自系统或其他应用特定消息的能力,这些消息可以是新闻推送、广告通知或者预警信息
CES(Common Event Service, 即公共事件服务)为应用程序提供发布、订阅及退订公共事件的能力。公共事件根据事件发送方不同可分为系统公共事件和自定义公共事件。 CES(Common Event Service, 即公共事件服务)为应用程序提供发布、订阅及退订公共事件的能力。公共事件根据事件发送方不同可分为系统公共事件和自定义公共事件。
...@@ -9,7 +9,7 @@ CES(Common Event Service, 即公共事件服务)为应用程序提供发布 ...@@ -9,7 +9,7 @@ CES(Common Event Service, 即公共事件服务)为应用程序提供发布
- 系统公共事件:系统将收集到的事件信息,根据系统策略发送给订阅该事件的用户程序。 公共事件包括:终端设备用户可感知的亮灭屏事件,以及系统关键服务发布的系统事件(例如:USB插拔,网络连接,系统升级)等。 - 系统公共事件:系统将收集到的事件信息,根据系统策略发送给订阅该事件的用户程序。 公共事件包括:终端设备用户可感知的亮灭屏事件,以及系统关键服务发布的系统事件(例如:USB插拔,网络连接,系统升级)等。
- 自定义公共事件:由应用自身定义的期望特定订阅者可以接收到的公共事件,这些公共事件往往与应用自身的业务逻辑相关。 - 自定义公共事件:由应用自身定义的期望特定订阅者可以接收到的公共事件,这些公共事件往往与应用自身的业务逻辑相关。
ANS(Advanced Notification Service,即通知增强服务)为应用程序提供发布通知的能力。这些通知常见的使用场景如下: ANS(Advanced Notification Service,即通知系统服务)为应用程序提供发布通知的能力。这些通知常见的使用场景如下:
- 显示接收到的短消息、即时通讯消息等; - 显示接收到的短消息、即时通讯消息等;
- 显示应用的推送消息,如广告、版本更新、新闻通知等; - 显示应用的推送消息,如广告、版本更新、新闻通知等;
......
...@@ -231,7 +231,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ ...@@ -231,7 +231,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
```js ```js
//公共事件相关信息 //公共事件相关信息
var options = { let options = {
code: 0, //公共事件的初始代码 code: 0, //公共事件的初始代码
data: "initial data",//公共事件的初始数据 data: "initial data",//公共事件的初始数据
isOrdered: true //有序公共事件 isOrdered: true //有序公共事件
...@@ -283,7 +283,7 @@ function PublishAsUserCallBack(err) { ...@@ -283,7 +283,7 @@ function PublishAsUserCallBack(err) {
} }
//指定发送的用户 //指定发送的用户
var userId = 100; let userId = 100;
//发布公共事件 //发布公共事件
CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack);
...@@ -315,7 +315,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca ...@@ -315,7 +315,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
```js ```js
//公共事件相关信息 //公共事件相关信息
var options = { let options = {
code: 0, //公共事件的初始代码 code: 0, //公共事件的初始代码
data: "initial data",//公共事件的初始数据 data: "initial data",//公共事件的初始数据
} }
...@@ -330,7 +330,7 @@ function PublishAsUserCallBack(err) { ...@@ -330,7 +330,7 @@ function PublishAsUserCallBack(err) {
} }
//指定发送的用户 //指定发送的用户
var userId = 100; let userId = 100;
//发布公共事件 //发布公共事件
CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack);
...@@ -357,10 +357,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ...@@ -357,10 +357,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
```js ```js
var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息 //订阅者信息
var subscribeInfo = { let subscribeInfo = {
events: ["event"] events: ["event"]
}; };
...@@ -402,10 +402,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS ...@@ -402,10 +402,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
**示例:** **示例:**
```js ```js
var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息 //订阅者信息
var subscribeInfo = { let subscribeInfo = {
events: ["event"] events: ["event"]
}; };
...@@ -438,10 +438,10 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven ...@@ -438,10 +438,10 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
**示例:** **示例:**
```js ```js
var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息 //订阅者信息
var subscribeInfo = { let subscribeInfo = {
events: ["event"] events: ["event"]
}; };
...@@ -490,10 +490,10 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): ...@@ -490,10 +490,10 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
**示例:** **示例:**
```js ```js
var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息 //订阅者信息
var subscribeInfo = { let subscribeInfo = {
events: ["event"] events: ["event"]
}; };
...@@ -553,7 +553,7 @@ getCode(callback: AsyncCallback\<number>): void ...@@ -553,7 +553,7 @@ getCode(callback: AsyncCallback\<number>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取有序公共事件的结果代码回调 //获取有序公共事件的结果代码回调
function getCodeCallback(err, Code) { function getCodeCallback(err, Code) {
...@@ -583,7 +583,7 @@ getCode(): Promise\<number> ...@@ -583,7 +583,7 @@ getCode(): Promise\<number>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.getCode().then((Code) => { subscriber.getCode().then((Code) => {
console.info("getCode " + JSON.stringify(Code)); console.info("getCode " + JSON.stringify(Code));
...@@ -610,7 +610,7 @@ setCode(code: number, callback: AsyncCallback\<void>): void ...@@ -610,7 +610,7 @@ setCode(code: number, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果代码回调 //设置有序公共事件的结果代码回调
function setCodeCallback(err) { function setCodeCallback(err) {
...@@ -646,7 +646,7 @@ setCode(code: number): Promise\<void> ...@@ -646,7 +646,7 @@ setCode(code: number): Promise\<void>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("setCode"); console.info("setCode");
...@@ -672,7 +672,7 @@ getData(callback: AsyncCallback\<string>): void ...@@ -672,7 +672,7 @@ getData(callback: AsyncCallback\<string>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取有序公共事件的结果数据回调 //获取有序公共事件的结果数据回调
function getDataCallback(err, Data) { function getDataCallback(err, Data) {
...@@ -702,7 +702,7 @@ getData(): Promise\<string> ...@@ -702,7 +702,7 @@ getData(): Promise\<string>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.getData().then((Data) => { subscriber.getData().then((Data) => {
console.info("getData " + JSON.stringify(Data)); console.info("getData " + JSON.stringify(Data));
...@@ -729,7 +729,7 @@ setData(data: string, callback: AsyncCallback\<void>): void ...@@ -729,7 +729,7 @@ setData(data: string, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果数据回调 //设置有序公共事件的结果数据回调
function setDataCallback(err) { function setDataCallback(err) {
...@@ -765,7 +765,7 @@ setData(data: string): Promise\<void> ...@@ -765,7 +765,7 @@ setData(data: string): Promise\<void>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("setData"); console.info("setData");
...@@ -793,7 +793,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void ...@@ -793,7 +793,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果代码和结果数据回调 //设置有序公共事件的结果代码和结果数据回调
function setCodeDataCallback(err) { function setCodeDataCallback(err) {
...@@ -830,7 +830,7 @@ setCodeAndData(code: number, data: string): Promise\<void> ...@@ -830,7 +830,7 @@ setCodeAndData(code: number, data: string): Promise\<void>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData"); console.info("setCodeAndData");
...@@ -858,7 +858,7 @@ isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void ...@@ -858,7 +858,7 @@ isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为有序事件的回调 //获取当前公共事件是否为有序事件的回调
function isOrderedCallback(err, isOrdered) { function isOrderedCallback(err, isOrdered) {
...@@ -890,7 +890,7 @@ isOrderedCommonEvent(): Promise\<boolean> ...@@ -890,7 +890,7 @@ isOrderedCommonEvent(): Promise\<boolean>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.isOrderedCommonEvent().then((isOrdered) => { subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered)); console.info("isOrdered " + JSON.stringify(isOrdered));
...@@ -918,7 +918,7 @@ isStickyCommonEvent(callback: AsyncCallback\<boolean>): void ...@@ -918,7 +918,7 @@ isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为粘性事件的回调 //获取当前公共事件是否为粘性事件的回调
function isStickyCallback(err, isSticky) { function isStickyCallback(err, isSticky) {
...@@ -950,7 +950,7 @@ isStickyCommonEvent(): Promise\<boolean> ...@@ -950,7 +950,7 @@ isStickyCommonEvent(): Promise\<boolean>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.isStickyCommonEvent().then((isSticky) => { subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky)); console.info("isSticky " + JSON.stringify(isSticky));
...@@ -976,7 +976,7 @@ abortCommonEvent(callback: AsyncCallback\<void>): void ...@@ -976,7 +976,7 @@ abortCommonEvent(callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//取消当前有序公共事件的回调 //取消当前有序公共事件的回调
function abortCallback(err) { function abortCallback(err) {
...@@ -1006,7 +1006,7 @@ abortCommonEvent(): Promise\<void> ...@@ -1006,7 +1006,7 @@ abortCommonEvent(): Promise\<void>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent"); console.info("abortCommonEvent");
...@@ -1032,7 +1032,7 @@ clearAbortCommonEvent(callback: AsyncCallback\<void>): void ...@@ -1032,7 +1032,7 @@ clearAbortCommonEvent(callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//清除当前公共事件取消状态的回调 //清除当前公共事件取消状态的回调
function clearAbortCallback(err) { function clearAbortCallback(err) {
...@@ -1062,7 +1062,7 @@ clearAbortCommonEvent(): Promise\<void> ...@@ -1062,7 +1062,7 @@ clearAbortCommonEvent(): Promise\<void>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent"); console.info("clearAbortCommonEvent");
...@@ -1088,7 +1088,7 @@ getAbortCommonEvent(callback: AsyncCallback\<boolean>): void ...@@ -1088,7 +1088,7 @@ getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取当前有序公共事件是否取消的回调 //获取当前有序公共事件是否取消的回调
function getAbortCallback(err, AbortCommonEvent) { function getAbortCallback(err, AbortCommonEvent) {
...@@ -1118,7 +1118,7 @@ getAbortCommonEvent(): Promise\<boolean> ...@@ -1118,7 +1118,7 @@ getAbortCommonEvent(): Promise\<boolean>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.getAbortCommonEvent().then((AbortCommonEvent) => { subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent)); console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
...@@ -1144,7 +1144,7 @@ getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void ...@@ -1144,7 +1144,7 @@ getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//获取订阅者信息回调 //获取订阅者信息回调
function getSubscribeInfoCallback(err, SubscribeInfo) { function getSubscribeInfoCallback(err, SubscribeInfo) {
...@@ -1174,7 +1174,7 @@ getSubscribeInfo(): Promise\<CommonEventSubscribeInfo> ...@@ -1174,7 +1174,7 @@ getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.getSubscribeInfo().then((SubscribeInfo) => { subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
...@@ -1200,7 +1200,7 @@ finishCommonEvent(callback: AsyncCallback\<void\>): void ...@@ -1200,7 +1200,7 @@ finishCommonEvent(callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
//结束当前有序公共事件的回调 //结束当前有序公共事件的回调
function finishCommonEventCallback(err) { function finishCommonEventCallback(err) {
...@@ -1230,7 +1230,7 @@ finishCommonEvent(): Promise\<void\> ...@@ -1230,7 +1230,7 @@ finishCommonEvent(): Promise\<void\>
**示例:** **示例:**
```js ```js
var subscriber; //创建成功的订阅者对象 let subscriber; //创建成功的订阅者对象
subscriber.finishCommonEvent().then(() => { subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
......
...@@ -39,10 +39,10 @@ on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata) ...@@ -39,10 +39,10 @@ on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata)
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | --------------------------------------- |
| event | [InnerEvent](#innerevent) | 是 | 持续订阅的事件 | | event | [InnerEvent](#innerevent) | 是 | 持续订阅的事件,其中EventPriority不生效 |
| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | | callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 |
**示例:** **示例:**
...@@ -66,10 +66,10 @@ once(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdat ...@@ -66,10 +66,10 @@ once(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdat
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | --------------------------------------- |
| event | [InnerEvent](#innerevent) | 是 | 单次订阅的事件 | | event | [InnerEvent](#innerevent) | 是 | 单次订阅的事件,其中EventPriority不生效 |
| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | | callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 |
**示例:** **示例:**
......
...@@ -34,7 +34,11 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void ...@@ -34,7 +34,11 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
```js ```js
//publish回调 //publish回调
function publishCallback(err) { function publishCallback(err) {
console.info("==========================>publishCallback=======================>"); if (err.code) {
console.info("publish failed " + JSON.stringify(err));
} else {
console.info("publish success");
}
} }
//通知Request对象 //通知Request对象
var notificationRequest = { var notificationRequest = {
...@@ -83,7 +87,7 @@ var notificationRequest = { ...@@ -83,7 +87,7 @@ var notificationRequest = {
} }
} }
Notification.publish(notificationRequest).then(() => { Notification.publish(notificationRequest).then(() => {
console.info("==========================>publishCallback=======================>"); console.info("publish sucess");
}); });
``` ```
...@@ -113,7 +117,11 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v ...@@ -113,7 +117,11 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
```js ```js
//publish回调 //publish回调
function publishCallback(err) { function publishCallback(err) {
console.info("==========================>publishCallback=======================>"); if (err.code) {
console.info("publish failed " + JSON.stringify(err));
} else {
console.info("publish success");
}
} }
// 接收通知的用户ID // 接收通知的用户ID
var userId = 1 var userId = 1
...@@ -169,7 +177,7 @@ var notificationRequest = { ...@@ -169,7 +177,7 @@ var notificationRequest = {
var userId = 1 var userId = 1
Notification.publish(notificationRequest, userId).then(() => { Notification.publish(notificationRequest, userId).then(() => {
console.info("==========================>publishCallback=======================>"); console.info("publish sucess");
}); });
``` ```
...@@ -195,7 +203,11 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void ...@@ -195,7 +203,11 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
```js ```js
//cancel回调 //cancel回调
function cancelCallback(err) { function cancelCallback(err) {
console.info("==========================>cancelCallback=======================>"); if (err.code) {
console.info("cancel failed " + JSON.stringify(err));
} else {
console.info("cancel success");
}
} }
Notification.cancel(0, "label", cancelCallback) Notification.cancel(0, "label", cancelCallback)
``` ```
...@@ -221,7 +233,7 @@ cancel(id: number, label?: string): Promise\<void\> ...@@ -221,7 +233,7 @@ cancel(id: number, label?: string): Promise\<void\>
```js ```js
Notification.cancel(0).then(() => { Notification.cancel(0).then(() => {
console.info("==========================>cancelCallback=======================>"); console.info("cancel sucess");
}); });
``` ```
...@@ -247,7 +259,11 @@ cancel(id: number, callback: AsyncCallback\<void\>): void ...@@ -247,7 +259,11 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
```js ```js
//cancel回调 //cancel回调
function cancelCallback(err) { function cancelCallback(err) {
console.info("==========================>cancelCallback=======================>"); if (err.code) {
console.info("cancel failed " + JSON.stringify(err));
} else {
console.info("cancel success");
}
} }
Notification.cancel(0, cancelCallback) Notification.cancel(0, cancelCallback)
``` ```
...@@ -273,7 +289,11 @@ cancelAll(callback: AsyncCallback\<void\>): void ...@@ -273,7 +289,11 @@ cancelAll(callback: AsyncCallback\<void\>): void
```js ```js
//cancel回调 //cancel回调
function cancelAllCallback(err) { function cancelAllCallback(err) {
console.info("==========================>cancelAllCallback=======================>"); if (err.code) {
console.info("cancelAll failed " + JSON.stringify(err));
} else {
console.info("cancelAll success");
}
} }
Notification.cancelAll(cancelAllCallback) Notification.cancelAll(cancelAllCallback)
``` ```
...@@ -292,7 +312,7 @@ cancelAll(): Promise\<void\> ...@@ -292,7 +312,7 @@ cancelAll(): Promise\<void\>
```js ```js
Notification.cancelAll().then(() => { Notification.cancelAll().then(() => {
console.info("==========================>cancelAllCallback=======================>"); console.info("cancelAll sucess");
}); });
``` ```
...@@ -322,7 +342,11 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void ...@@ -322,7 +342,11 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
```js ```js
//addslot回调 //addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
console.info("==========================>addSlotCallBack=======================>"); if (err.code) {
console.info("addSlot failed " + JSON.stringify(err));
} else {
console.info("addSlot success");
}
} }
//通知slot对象 //通知slot对象
var notificationSlot = { var notificationSlot = {
...@@ -359,7 +383,7 @@ var notificationSlot = { ...@@ -359,7 +383,7 @@ var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} }
Notification.addSlot(notificationSlot).then(() => { Notification.addSlot(notificationSlot).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("addSlot sucess");
}); });
``` ```
...@@ -385,7 +409,11 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void ...@@ -385,7 +409,11 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
```js ```js
//addslot回调 //addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
console.info("==========================>addSlotCallBack=======================>"); if (err.code) {
console.info("addSlot failed " + JSON.stringify(err));
} else {
console.info("addSlot success");
}
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)
``` ```
...@@ -410,7 +438,7 @@ addSlot(type: SlotType): Promise\<void\> ...@@ -410,7 +438,7 @@ addSlot(type: SlotType): Promise\<void\>
```js ```js
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("addSlot sucess");
}); });
``` ```
...@@ -440,7 +468,11 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi ...@@ -440,7 +468,11 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
```js ```js
//addSlots回调 //addSlots回调
function addSlotsCallBack(err) { function addSlotsCallBack(err) {
console.info("==========================>addSlotsCallBack=======================>"); if (err.code) {
console.info("addSlots failed " + JSON.stringify(err));
} else {
console.info("addSlots success");
}
} }
//通知slot对象 //通知slot对象
var notificationSlot = { var notificationSlot = {
...@@ -485,7 +517,7 @@ var notificationSlotArray = new Array(); ...@@ -485,7 +517,7 @@ var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { Notification.addSlots(notificationSlotArray).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("addSlots sucess");
}); });
``` ```
...@@ -511,7 +543,11 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void ...@@ -511,7 +543,11 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
```js ```js
//getSlot回调 //getSlot回调
function getSlotCallback(err,data) { function getSlotCallback(err,data) {
console.info("==========================>getSlotCallback=======================>"); if (err.code) {
console.info("getSlot failed " + JSON.stringify(err));
} else {
console.info("getSlot success");
}
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) Notification.getSlot(slotType, getSlotCallback)
...@@ -544,7 +580,7 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\> ...@@ -544,7 +580,7 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { Notification.getSlot(slotType).then((data) => {
console.info("==========================>getSlotCallback=======================>"); console.info("getSlot sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -569,7 +605,11 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void ...@@ -569,7 +605,11 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
```js ```js
//getSlots回调 //getSlots回调
function getSlotsCallback(err,data) { function getSlotsCallback(err,data) {
console.info("==========================>getSlotsCallback=======================>"); if (err.code) {
console.info("getSlots failed " + JSON.stringify(err));
} else {
console.info("getSlots success");
}
} }
Notification.getSlots(getSlotsCallback) Notification.getSlots(getSlotsCallback)
``` ```
...@@ -594,7 +634,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>> ...@@ -594,7 +634,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>>
```js ```js
Notification.getSlots().then((data) => { Notification.getSlots().then((data) => {
console.info("==========================>getSlotsCallback=======================>"); console.info("getSlots sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -620,7 +660,11 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void ...@@ -620,7 +660,11 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
```js ```js
//removeSlot回调 //removeSlot回调
function removeSlotCallback(err) { function removeSlotCallback(err) {
console.info("==========================>removeSlotCallback=======================>"); if (err.code) {
console.info("removeSlot failed " + JSON.stringify(err));
} else {
console.info("removeSlot success");
}
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) Notification.removeSlot(slotType,removeSlotCallback)
...@@ -647,7 +691,7 @@ removeSlot(slotType: SlotType): Promise\<void\> ...@@ -647,7 +691,7 @@ removeSlot(slotType: SlotType): Promise\<void\>
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { Notification.removeSlot(slotType).then(() => {
console.info("==========================>removeSlotCallback=======================>"); console.info("removeSlot sucess");
}); });
``` ```
...@@ -671,7 +715,11 @@ removeAllSlots(callback: AsyncCallback\<void\>): void ...@@ -671,7 +715,11 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
```js ```js
function removeAllCallBack(err) { function removeAllCallBack(err) {
console.info("================>removeAllCallBack=======================>"); if (err.code) {
console.info("removeAllSlots failed " + JSON.stringify(err));
} else {
console.info("removeAllSlots success");
}
} }
Notification.removeAllSlots(removeAllCallBack) Notification.removeAllSlots(removeAllCallBack)
``` ```
...@@ -690,7 +738,7 @@ removeAllSlots(): Promise\<void\> ...@@ -690,7 +738,7 @@ removeAllSlots(): Promise\<void\>
```js ```js
Notification.removeAllSlots().then(() => { Notification.removeAllSlots().then(() => {
console.info("==========================>removeAllCallBack=======================>"); console.info("removeAllSlots sucess");
}); });
``` ```
...@@ -721,10 +769,14 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ...@@ -721,10 +769,14 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
```js ```js
//subscribe回调 //subscribe回调
function subscribeCallback(err) { function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>"); if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe success");
}
} }
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
...@@ -760,10 +812,14 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): ...@@ -760,10 +812,14 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
```js ```js
function subscribeCallback(err) { function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>"); if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe success");
}
} }
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
...@@ -796,13 +852,17 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -796,13 +852,17 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
```js ```js
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe success");
}
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.subscribe(subscriber).then(() => { Notification.subscribe(subscriber).then(() => {
console.info("==========================>subscribeCallback=======================>"); console.info("subscribe sucess");
}); });
``` ```
...@@ -831,13 +891,17 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>) ...@@ -831,13 +891,17 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
```js ```js
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
console.info("==========================>unsubscribeCallback=======================>"); if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribe success");
}
} }
function onConsumeCallback(data) { function onCancelCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onCancel: onCancelCallback
} }
Notification.unsubscribe(subscriber, unsubscribeCallback); Notification.unsubscribe(subscriber, unsubscribeCallback);
``` ```
...@@ -865,14 +929,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -865,14 +929,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:** **示例:**
```js ```js
function onConsumeCallback(data) { function onCancelCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onCancel: onCancelCallback
}; };
Notification.unsubscribe(subscriber).then(() => { Notification.unsubscribe(subscriber).then(() => {
console.info("==========================>unsubscribeCallback=======================>"); console.info("unsubscribe sucess");
}); });
``` ```
...@@ -902,7 +966,11 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac ...@@ -902,7 +966,11 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac
```js ```js
function enableNotificationCallback(err) { function enableNotificationCallback(err) {
console.info("==========================>enableNotificationCallback=======================>"); if (err.code) {
console.info("enableNotification failed " + JSON.stringify(err));
} else {
console.info("enableNotification success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -938,7 +1006,7 @@ var bundle = { ...@@ -938,7 +1006,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.enableNotification(bundle, false).then(() => { Notification.enableNotification(bundle, false).then(() => {
console.info("==========================>enableNotificationCallback=======================>"); console.info("enableNotification sucess");
}); });
``` ```
...@@ -967,7 +1035,11 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): ...@@ -967,7 +1035,11 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
```js ```js
function isNotificationEnabledCallback(err, data) { function isNotificationEnabledCallback(err, data) {
console.info("==========================>isNotificationEnabledCallback=======================>"); if (err.code) {
console.info("isNotificationEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationEnabled success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1008,7 +1080,7 @@ var bundle = { ...@@ -1008,7 +1080,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("==========================>isNotificationEnabledCallback=======================>"); console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1036,7 +1108,11 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void ...@@ -1036,7 +1108,11 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
```js ```js
function isNotificationEnabledCallback(err, data) { function isNotificationEnabledCallback(err, data) {
console.info("==========================>isNotificationEnabledCallback=======================>"); if (err.code) {
console.info("isNotificationEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationEnabled success");
}
} }
Notification.isNotificationEnabled(isNotificationEnabledCallback); Notification.isNotificationEnabled(isNotificationEnabledCallback);
...@@ -1072,7 +1148,7 @@ isNotificationEnabled(): Promise\<boolean\> ...@@ -1072,7 +1148,7 @@ isNotificationEnabled(): Promise\<boolean\>
```js ```js
Notification.isNotificationEnabled().then((data) => { Notification.isNotificationEnabled().then((data) => {
console.info("==========================>isNotificationEnabledCallback=======================>"); console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1102,7 +1178,11 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi ...@@ -1102,7 +1178,11 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
```js ```js
function displayBadgeCallback(err) { function displayBadgeCallback(err) {
console.info("==========================>displayBadgeCallback=======================>"); if (err.code) {
console.info("displayBadge failed " + JSON.stringify(err));
} else {
console.info("displayBadge success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1138,7 +1218,7 @@ var bundle = { ...@@ -1138,7 +1218,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.displayBadge(bundle, false).then(() => { Notification.displayBadge(bundle, false).then(() => {
console.info("==========================>displayBadgeCallback=======================>"); console.info("displayBadge sucess");
}); });
``` ```
...@@ -1167,7 +1247,11 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void ...@@ -1167,7 +1247,11 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
```js ```js
function isBadgeDisplayedCallback(err, data) { function isBadgeDisplayedCallback(err, data) {
console.info("==========================>isBadgeDisplayedCallback=======================>"); if (err.code) {
console.info("isBadgeDisplayed failed " + JSON.stringify(err));
} else {
console.info("isBadgeDisplayed success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1208,7 +1292,7 @@ var bundle = { ...@@ -1208,7 +1292,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("==========================>isBadgeDisplayedCallback=======================>"); console.info("isBadgeDisplayed sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1238,7 +1322,11 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal ...@@ -1238,7 +1322,11 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
```js ```js
function setSlotByBundleCallback(err) { function setSlotByBundleCallback(err) {
console.info("==========================>setSlotByBundleCallback=======================>"); if (err.code) {
console.info("setSlotByBundle failed " + JSON.stringify(err));
} else {
console.info("setSlotByBundle success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1280,7 +1368,7 @@ var notificationSlot = { ...@@ -1280,7 +1368,7 @@ var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} }
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("==========================>setSlotByBundleCallback=======================>"); console.info("setSlotByBundle sucess");
}); });
``` ```
...@@ -1309,7 +1397,11 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati ...@@ -1309,7 +1397,11 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
```js ```js
function getSlotsByBundleCallback(err, data) { function getSlotsByBundleCallback(err, data) {
console.info("==========================>getSlotsByBundleCallback=======================>"); if (err.code) {
console.info("getSlotsByBundle failed " + JSON.stringify(err));
} else {
console.info("getSlotsByBundle success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1350,7 +1442,7 @@ var bundle = { ...@@ -1350,7 +1442,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("==========================>getSlotsByBundleCallback=======================>"); console.info("getSlotsByBundle sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1379,7 +1471,11 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi ...@@ -1379,7 +1471,11 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
```js ```js
function getSlotNumByBundleCallback(err, data) { function getSlotNumByBundleCallback(err, data) {
console.info("==========================>getSlotNumByBundleCallback=======================>"); if (err.code) {
console.info("getSlotNumByBundle failed " + JSON.stringify(err));
} else {
console.info("getSlotNumByBundle success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1420,7 +1516,7 @@ var bundle = { ...@@ -1420,7 +1516,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("==========================>getSlotNumByBundleCallback=======================>"); console.info("getSlotNumByBundle sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1451,7 +1547,11 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -1451,7 +1547,11 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
```js ```js
function removeCallback(err) { function removeCallback(err) {
console.info("==========================>removeCallback=======================>"); if (err.code) {
console.info("remove failed " + JSON.stringify(err));
} else {
console.info("remove success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1498,7 +1598,7 @@ var notificationKey = { ...@@ -1498,7 +1598,7 @@ var notificationKey = {
} }
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; var reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason).then(() => { Notification.remove(bundle, notificationKey, reason).then(() => {
console.info("==========================>removeCallback=======================>"); console.info("remove sucess");
}); });
``` ```
...@@ -1530,7 +1630,11 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): ...@@ -1530,7 +1630,11 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
var hashCode = 'hashCode' var hashCode = 'hashCode'
function removeCallback(err) { function removeCallback(err) {
console.info("==========================>removeCallback=======================>"); if (err.code) {
console.info("remove failed " + JSON.stringify(err));
} else {
console.info("remove success");
}
} }
var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
Notification.remove(hashCode, reason, removeCallback); Notification.remove(hashCode, reason, removeCallback);
...@@ -1563,7 +1667,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -1563,7 +1667,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
var hashCode = 'hashCode' var hashCode = 'hashCode'
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; var reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(hashCode, reason).then(() => { Notification.remove(hashCode, reason).then(() => {
console.info("==========================>removeCallback=======================>"); console.info("remove sucess");
}); });
``` ```
...@@ -1592,7 +1696,11 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void ...@@ -1592,7 +1696,11 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
console.info("==========================>removeAllCallback=======================>"); if (err.code) {
console.info("removeAll failed " + JSON.stringify(err));
} else {
console.info("removeAll success");
}
} }
var bundle = { var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
...@@ -1624,7 +1732,11 @@ removeAll(callback: AsyncCallback\<void\>): void ...@@ -1624,7 +1732,11 @@ removeAll(callback: AsyncCallback\<void\>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
console.info("==========================>removeAllCallback=======================>"); if (err.code) {
console.info("removeAll failed " + JSON.stringify(err));
} else {
console.info("removeAll success");
}
} }
Notification.removeAll(removeAllCallback); Notification.removeAll(removeAllCallback);
...@@ -1654,7 +1766,7 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -1654,7 +1766,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
```js ```js
Notification.removeAll().then(() => { Notification.removeAll().then(() => {
console.info("==========================>removeAllCallback=======================>"); console.info("removeAll sucess");
}); });
``` ```
...@@ -1681,7 +1793,11 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void ...@@ -1681,7 +1793,11 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
console.info("==========================>removeAllCallback=======================>"); if (err.code) {
console.info("removeAll failed " + JSON.stringify(err));
} else {
console.info("removeAll success");
}
} }
var userId = 1 var userId = 1
...@@ -1711,7 +1827,11 @@ removeAll(userId: number): Promise\<void> ...@@ -1711,7 +1827,11 @@ removeAll(userId: number): Promise\<void>
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
console.info("==========================>removeAllCallback=======================>"); if (err.code) {
console.info("removeAll failed " + JSON.stringify(err));
} else {
console.info("removeAll success");
}
} }
var userId = 1 var userId = 1
...@@ -1742,7 +1862,11 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>) ...@@ -1742,7 +1862,11 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>)
```js ```js
function getAllActiveNotificationsCallback(err, data) { function getAllActiveNotificationsCallback(err, data) {
console.info("==========================>getAllActiveNotificationsCallback=======================>"); if (err.code) {
console.info("getAllActiveNotifications failed " + JSON.stringify(err));
} else {
console.info("getAllActiveNotifications success");
}
} }
Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
...@@ -1772,7 +1896,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification ...@@ -1772,7 +1896,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification
```js ```js
Notification.getAllActiveNotifications().then((data) => { Notification.getAllActiveNotifications().then((data) => {
console.info("==========================>getAllActiveNotificationsCallback=======================>"); console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1796,7 +1920,11 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void ...@@ -1796,7 +1920,11 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
```js ```js
function getActiveNotificationCountCallback(err, data) { function getActiveNotificationCountCallback(err, data) {
console.info("==========================>getActiveNotificationCountCallback=======================>"); if (err.code) {
console.info("getActiveNotificationCount failed " + JSON.stringify(err));
} else {
console.info("getActiveNotificationCount success");
}
} }
Notification.getActiveNotificationCount(getActiveNotificationCountCallback); Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
...@@ -1822,7 +1950,7 @@ getActiveNotificationCount(): Promise\<number\> ...@@ -1822,7 +1950,7 @@ getActiveNotificationCount(): Promise\<number\>
```js ```js
Notification.getActiveNotificationCount().then((data) => { Notification.getActiveNotificationCount().then((data) => {
console.info("==========================>getActiveNotificationCountCallback=======================>"); console.info("getActiveNotificationCount sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1846,7 +1974,11 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v ...@@ -1846,7 +1974,11 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v
```js ```js
function getActiveNotificationsCallback(err, data) { function getActiveNotificationsCallback(err, data) {
console.info("==========================>getActiveNotificationsCallback=======================>"); if (err.code) {
console.info("getActiveNotifications failed " + JSON.stringify(err));
} else {
console.info("getActiveNotifications success");
}
} }
Notification.getActiveNotifications(getActiveNotificationsCallback); Notification.getActiveNotifications(getActiveNotificationsCallback);
...@@ -1872,7 +2004,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationreq ...@@ -1872,7 +2004,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationreq
```js ```js
Notification.getActiveNotifications().then((data) => { Notification.getActiveNotifications().then((data) => {
console.info("==========================>getActiveNotificationsCallback=======================>"); console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1897,7 +2029,11 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void ...@@ -1897,7 +2029,11 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
```js ```js
function cancelGroupCallback(err) { function cancelGroupCallback(err) {
console.info("==========================>cancelGroupCallback=======================>"); if (err.code) {
console.info("cancelGroup failed " + JSON.stringify(err));
} else {
console.info("cancelGroup success");
}
} }
var groupName = "GroupName"; var groupName = "GroupName";
...@@ -1926,7 +2062,7 @@ cancelGroup(groupName: string): Promise\<void\> ...@@ -1926,7 +2062,7 @@ cancelGroup(groupName: string): Promise\<void\>
```js ```js
var groupName = "GroupName"; var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { Notification.cancelGroup(groupName).then(() => {
console.info("==========================>cancelGroupPromise=======================>"); console.info("cancelGroup sucess");
}); });
``` ```
...@@ -1956,7 +2092,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall ...@@ -1956,7 +2092,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
```js ```js
function removeGroupByBundleCallback(err) { function removeGroupByBundleCallback(err) {
console.info("==========================>removeGroupByBundleCallback=======================>"); if (err.code) {
console.info("removeGroupByBundle failed " + JSON.stringify(err));
} else {
console.info("removeGroupByBundle success");
}
} }
var bundleOption = {bundle: "Bundle"}; var bundleOption = {bundle: "Bundle"};
...@@ -1992,7 +2132,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> ...@@ -1992,7 +2132,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
var bundleOption = {bundle: "Bundle"}; var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("==========================>removeGroupByBundlePromise=======================>"); console.info("removeGroupByBundle sucess");
}); });
``` ```
...@@ -2021,7 +2161,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo ...@@ -2021,7 +2161,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
```js ```js
function setDoNotDisturbDateCallback(err) { function setDoNotDisturbDateCallback(err) {
console.info("==========================>setDoNotDisturbDateCallback=======================>"); if (err.code) {
console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
} else {
console.info("setDoNotDisturbDate success");
}
} }
var doNotDisturbDate = { var doNotDisturbDate = {
...@@ -2062,7 +2206,7 @@ var doNotDisturbDate = { ...@@ -2062,7 +2206,7 @@ var doNotDisturbDate = {
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} }
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("==========================>setDoNotDisturbDatePromise=======================>"); console.info("setDoNotDisturbDate sucess");
}); });
``` ```
...@@ -2091,7 +2235,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb ...@@ -2091,7 +2235,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
```js ```js
function setDoNotDisturbDateCallback(err) { function setDoNotDisturbDateCallback(err) {
console.info("==========================>setDoNotDisturbDateCallback=======================>"); if (err.code) {
console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
} else {
console.info("setDoNotDisturbDate success");
}
} }
var doNotDisturbDate = { var doNotDisturbDate = {
...@@ -2138,7 +2286,7 @@ var doNotDisturbDate = { ...@@ -2138,7 +2286,7 @@ var doNotDisturbDate = {
var userId = 1 var userId = 1
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("==========================>setDoNotDisturbDatePromise=======================>"); console.info("setDoNotDisturbDate sucess");
}); });
``` ```
...@@ -2165,7 +2313,11 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void ...@@ -2165,7 +2313,11 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
```js ```js
function getDoNotDisturbDateCallback(err,data) { function getDoNotDisturbDateCallback(err,data) {
console.info("==========================>getDoNotDisturbDateCallback=======================>"); if (err.code) {
console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
} else {
console.info("getDoNotDisturbDate success");
}
} }
Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
...@@ -2195,7 +2347,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> ...@@ -2195,7 +2347,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
```js ```js
Notification.getDoNotDisturbDate().then((data) => { Notification.getDoNotDisturbDate().then((data) => {
console.info("==========================>getDoNotDisturbDatePromise=======================>"); console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2223,7 +2375,11 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>) ...@@ -2223,7 +2375,11 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
```js ```js
function getDoNotDisturbDateCallback(err,data) { function getDoNotDisturbDateCallback(err,data) {
console.info("==========================>getDoNotDisturbDateCallback=======================>"); if (err.code) {
console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
} else {
console.info("getDoNotDisturbDate success");
}
} }
var userId = 1 var userId = 1
...@@ -2263,7 +2419,7 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> ...@@ -2263,7 +2419,7 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
var userId = 1 var userId = 1
Notification.getDoNotDisturbDate(userId).then((data) => { Notification.getDoNotDisturbDate(userId).then((data) => {
console.info("==========================>getDoNotDisturbDatePromise=======================>"); console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2290,7 +2446,11 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void ...@@ -2290,7 +2446,11 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
```js ```js
function supportDoNotDisturbModeCallback(err,data) { function supportDoNotDisturbModeCallback(err,data) {
console.info("==========================>supportDoNotDisturbModeCallback=======================>"); if (err.code) {
console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
} else {
console.info("supportDoNotDisturbMode success");
}
} }
Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
...@@ -2320,7 +2480,7 @@ supportDoNotDisturbMode(): Promise\<boolean\> ...@@ -2320,7 +2480,7 @@ supportDoNotDisturbMode(): Promise\<boolean\>
```js ```js
Notification.supportDoNotDisturbMode().then((data) => { Notification.supportDoNotDisturbMode().then((data) => {
console.info("==========================>supportDoNotDisturbModePromise=======================>"); console.info("supportDoNotDisturbMode sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2346,7 +2506,11 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi ...@@ -2346,7 +2506,11 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
```javascript ```javascript
var templateName = 'process'; var templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
console.info("isSupportTemplateCallback"); if (err.code) {
console.info("isSupportTemplate failed " + JSON.stringify(err));
} else {
console.info("isSupportTemplate success");
}
} }
Notification.isSupportTemplate(templateName, isSupportTemplateCallback); Notification.isSupportTemplate(templateName, isSupportTemplateCallback);
...@@ -2380,7 +2544,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\> ...@@ -2380,7 +2544,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
var templateName = 'process'; var templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { Notification.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplateCallback"); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2404,7 +2568,11 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void ...@@ -2404,7 +2568,11 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
```javascript ```javascript
function requestEnableNotificationCallback() { function requestEnableNotificationCallback() {
console.log('------------- requestEnabledNotification --------------'); if (err.code) {
console.info("requestEnableNotification failed " + JSON.stringify(err));
} else {
console.info("requestEnableNotification success");
}
}; };
Notification.requestEnableNotification(requestEnableNotificationCallback); Notification.requestEnableNotification(requestEnableNotificationCallback);
...@@ -2425,7 +2593,7 @@ requestEnableNotification(): Promise\<void\> ...@@ -2425,7 +2593,7 @@ requestEnableNotification(): Promise\<void\>
```javascript ```javascript
Notification.requestEnableNotification() Notification.requestEnableNotification()
.then(() => { .then(() => {
console.info("requestEnableNotification "); console.info("requestEnableNotification sucess");
}); });
``` ```
...@@ -2453,7 +2621,11 @@ enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void ...@@ -2453,7 +2621,11 @@ enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
```javascript ```javascript
function enabledNotificationCallback() { function enabledNotificationCallback() {
console.log('----------- enableDistributed ------------'); if (err.code) {
console.info("enableDistributed failed " + JSON.stringify(err));
} else {
console.info("enableDistributed success");
}
}; };
var enable = true var enable = true
...@@ -2488,7 +2660,7 @@ var enable = true ...@@ -2488,7 +2660,7 @@ var enable = true
Notification.enableDistributed(enable) Notification.enableDistributed(enable)
.then(() => { .then(() => {
console.log('-------- enableDistributed ----------'); console.info("enableDistributed sucess");
}); });
``` ```
...@@ -2511,7 +2683,11 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void ...@@ -2511,7 +2683,11 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
```javascript ```javascript
function isDistributedEnabledCallback() { function isDistributedEnabledCallback() {
console.log('----------- isDistributedEnabled ------------'); if (err.code) {
console.info("isDistributedEnabled failed " + JSON.stringify(err));
} else {
console.info("isDistributedEnabled success");
}
}; };
Notification.isDistributedEnabled(isDistributedEnabledCallback); Notification.isDistributedEnabled(isDistributedEnabledCallback);
...@@ -2538,7 +2714,7 @@ isDistributedEnabled(): Promise\<boolean> ...@@ -2538,7 +2714,7 @@ isDistributedEnabled(): Promise\<boolean>
```javascript ```javascript
Notification.isDistributedEnabled() Notification.isDistributedEnabled()
.then((data) => { .then((data) => {
console.log('-------- isDistributedEnabled ----------'); console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2567,7 +2743,11 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async ...@@ -2567,7 +2743,11 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async
```javascript ```javascript
function enableDistributedByBundleCallback() { function enableDistributedByBundleCallback() {
console.log('----------- enableDistributedByBundle ------------'); if (err.code) {
console.info("enableDistributedByBundle failed " + JSON.stringify(err));
} else {
console.info("enableDistributedByBundle success");
}
}; };
var bundle = { var bundle = {
...@@ -2611,7 +2791,7 @@ var enable = true ...@@ -2611,7 +2791,7 @@ var enable = true
Notification.enableDistributedByBundle(bundle, enable) Notification.enableDistributedByBundle(bundle, enable)
.then(() => { .then(() => {
console.log('-------- enableDistributedByBundle ----------'); console.info("enableDistributedByBundle sucess");
}); });
``` ```
...@@ -2638,7 +2818,11 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool ...@@ -2638,7 +2818,11 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
```javascript ```javascript
function isDistributedEnabledByBundleCallback(data) { function isDistributedEnabledByBundleCallback(data) {
console.log('----------- isDistributedEnabledByBundle ------------', data); if (err.code) {
console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
} else {
console.info("isDistributedEnabledByBundle success");
}
}; };
var bundle = { var bundle = {
...@@ -2683,7 +2867,7 @@ var bundle = { ...@@ -2683,7 +2867,7 @@ var bundle = {
Notification.isDistributedEnabledByBundle(bundle) Notification.isDistributedEnabledByBundle(bundle)
.then((data) => { .then((data) => {
console.log('-------- isDistributedEnabledByBundle ----------', data); console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2710,7 +2894,11 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void ...@@ -2710,7 +2894,11 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
```javascript ```javascript
function getDeviceRemindTypeCallback(data) { function getDeviceRemindTypeCallback(data) {
console.log('----------- getDeviceRemindType ------------', data); if (err.code) {
console.info("getDeviceRemindType failed " + JSON.stringify(err));
} else {
console.info("getDeviceRemindType success");
}
}; };
Notification.getDeviceRemindType(getDeviceRemindTypeCallback); Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
...@@ -2741,7 +2929,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\> ...@@ -2741,7 +2929,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
```javascript ```javascript
Notification.getDeviceRemindType() Notification.getDeviceRemindType()
.then((data) => { .then((data) => {
console.log('-------- getDeviceRemindType ----------', data); console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2772,7 +2960,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -2772,7 +2960,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```js ```js
//publishAsBundle回调 //publishAsBundle回调
function publishAsBundleCallback(err) { function publishAsBundleCallback(err) {
console.info("==========================>publishAsBundleCallback=======================>"); if (err.code) {
console.info("publishAsBundle failed " + JSON.stringify(err));
} else {
console.info("publishAsBundle success");
}
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo"
...@@ -2836,7 +3028,7 @@ var notificationRequest = { ...@@ -2836,7 +3028,7 @@ var notificationRequest = {
} }
Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => {
console.info("==========================>publishAsBundleCallback=======================>"); console.info("publishAsBundle sucess");
}); });
``` ```
...@@ -2868,7 +3060,11 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac ...@@ -2868,7 +3060,11 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
```js ```js
//cancelAsBundle //cancelAsBundle
function cancelAsBundleCallback(err) { function cancelAsBundleCallback(err) {
console.info("==========================>cancelAsBundleCallback=======================>"); if (err.code) {
console.info("cancelAsBundle failed " + JSON.stringify(err));
} else {
console.info("cancelAsBundle success");
}
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo"
...@@ -2909,7 +3105,7 @@ let representativeBundle = "com.example.demo" ...@@ -2909,7 +3105,7 @@ let representativeBundle = "com.example.demo"
let userId = 100 let userId = 100
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("==========================>cancelAsBundleCallback=======================>"); console.info("cancelAsBundle success");
}); });
``` ```
...@@ -2939,7 +3135,11 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca ...@@ -2939,7 +3135,11 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca
```js ```js
//enableNotificationSlot //enableNotificationSlot
function enableSlotCallback(err) { function enableSlotCallback(err) {
console.log('===================>enableSlotCallback==================>'); if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err));
} else {
console.info("enableNotificationSlot success");
}
}; };
Notification.enableNotificationSlot( Notification.enableNotificationSlot(
...@@ -2977,7 +3177,7 @@ Notification.enableNotificationSlot( ...@@ -2977,7 +3177,7 @@ Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION, Notification.SlotType.SOCIAL_COMMUNICATION,
true).then(() => { true).then(() => {
console.log('====================>enableNotificationSlot====================>'); console.info("enableNotificationSlot sucess");
}); });
``` ```
...@@ -3006,7 +3206,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ...@@ -3006,7 +3206,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
```js ```js
//isNotificationSlotEnabled //isNotificationSlotEnabled
function getEnableSlotCallback(err, data) { function getEnableSlotCallback(err, data) {
console.log('===================>getEnableSlotCallback=================='); if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationSlotEnabled success");
}
}; };
Notification.isNotificationSlotEnabled( Notification.isNotificationSlotEnabled(
...@@ -3048,7 +3252,7 @@ Notification.isNotificationSlotEnabled( ...@@ -3048,7 +3252,7 @@ Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION Notification.SlotType.SOCIAL_COMMUNICATION
).then((data) => { ).then((data) => {
console.log('====================>isNotificationSlotEnabled====================>'); console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -3080,7 +3284,11 @@ let userId = 100; ...@@ -3080,7 +3284,11 @@ let userId = 100;
let enable = true; let enable = true;
function setSyncNotificationEnabledWithoutAppCallback(err) { function setSyncNotificationEnabledWithoutAppCallback(err) {
console.log('setSyncNotificationEnabledWithoutAppCallback'); if (err.code) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else {
console.info("setSyncNotificationEnabledWithoutApp success");
}
} }
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback); Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
...@@ -3119,11 +3327,11 @@ let userId = 100; ...@@ -3119,11 +3327,11 @@ let userId = 100;
let enable = true; let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable) Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
.then((data) => { .then(() => {
console.log('setSyncNotificationEnabledWithoutApp'); console.info('setSyncNotificationEnabledWithoutApp');
}) })
.catch((err) => { .catch((err) => {
console.log('setSyncNotificationEnabledWithoutApp, err:', err); console.info('setSyncNotificationEnabledWithoutApp, err:', err);
}); });
``` ```
...@@ -3154,9 +3362,9 @@ let userId = 100; ...@@ -3154,9 +3362,9 @@ let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(data, err) { function getSyncNotificationEnabledWithoutAppCallback(data, err) {
if (err) { if (err) {
console.log('getSyncNotificationEnabledWithoutAppCallback, err' + err); console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err);
} else { } else {
console.log('getSyncNotificationEnabledWithoutAppCallback, data' + data); console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data);
} }
} }
...@@ -3195,10 +3403,10 @@ let userId = 100; ...@@ -3195,10 +3403,10 @@ let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId) Notification.getSyncNotificationEnabledWithoutApp(userId)
.then((data) => { .then((data) => {
console.log('getSyncNotificationEnabledWithoutApp, data:', data); console.info('getSyncNotificationEnabledWithoutApp, data:', data);
}) })
.catch((err) => { .catch((err) => {
console.log('getSyncNotificationEnabledWithoutApp, err:', err); console.info('getSyncNotificationEnabledWithoutApp, err:', err);
}); });
``` ```
...@@ -3242,7 +3450,7 @@ function onConsumeCallback(data) { ...@@ -3242,7 +3450,7 @@ function onConsumeCallback(data) {
let wantAgent = data.wantAgent; let wantAgent = data.wantAgent;
wantAgent .getWant(wantAgent) wantAgent .getWant(wantAgent)
.then((data1) => { .then((data1) => {
console.log('===> getWant success want:' + JSON.stringify(data1)); console.info('===> getWant success want:' + JSON.stringify(data1));
}) })
.catch((err) => { .catch((err) => {
console.error('===> getWant failed because' + JSON.stringify(err)); console.error('===> getWant failed because' + JSON.stringify(err));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册