diff --git a/README.md b/README.md index 3202e70581def03f1236e4f86ad88089c724bbe1..621a9fde7b465e01cb446a95e3f7f589086189b5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ 2. 在首页勾选文件后,通过碰一碰即可分享已选文件。 3. 若接收端为PC设备,需确保手机与PC登录同一华为账号,方可实现碰一碰分享。 4. 接收端文件默认存储于图库或文件管理器中,其中PC端应用可通过调用harmonyShare.on('dataReceive')方法注册文件接收监听,碰一碰传输的文件将存储至该应用的沙箱路径下。 +5. PC端应用接收时最大支持接收5个支持。 ### 工程结构 diff --git a/entry/src/main/ets/controller/KnockController.ets b/entry/src/main/ets/controller/KnockController.ets index 7b65f443b4ba41d8ea2a41bbf1f032d1a4cd531c..95dc7f96b2e4c5caaea0b157856bce8068ec2e43 100644 --- a/entry/src/main/ets/controller/KnockController.ets +++ b/entry/src/main/ets/controller/KnockController.ets @@ -140,7 +140,16 @@ export class KnockController { public dataReceiveListeningPC() { window.getLastWindow(this.context).then(((data) => { let mainWindowID: number = data.getWindowProperties().id; - harmonyShare.on('dataReceive', { windowId: mainWindowID, capabilities: [] }, + harmonyShare.on('dataReceive', { windowId: mainWindowID, capabilities: [ + { + 'utd': uniformTypeDescriptor.UniformDataType.MEDIA, + 'maxSupportedCount': 5 + }, + { + 'utd': uniformTypeDescriptor.UniformDataType.FILE, + 'maxSupportedCount': 5 + } + ] }, (receiveTarget: harmonyShare.ReceivableTarget) => { if (!this.context) { return; @@ -197,7 +206,16 @@ export class KnockController { public dataReceiveDisableListeningPC() { window.getLastWindow(this.context).then(((data) => { let mainWindowID: number = data.getWindowProperties().id; - harmonyShare.off('dataReceive', { windowId: mainWindowID, capabilities: [] }); + harmonyShare.off('dataReceive', { windowId: mainWindowID, capabilities: [ + { + 'utd': uniformTypeDescriptor.UniformDataType.MEDIA, + 'maxSupportedCount': 5 + }, + { + 'utd': uniformTypeDescriptor.UniformDataType.FILE, + 'maxSupportedCount': 5 + } + ] }); })).catch((error: BusinessError) => { hilog.error(0x0000, 'KnockFileShare', `failed to obtain the window. cause ${error.code} ${error.message}`); })