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