代码拉取完成,页面将自动刷新
本示例主要介绍开发者如何调用Native Notification接口使用通知服务。当前功能包含查询当前应用通知使能状态。
主页 | 弹窗显示关闭通知使能状态 | 弹窗显示开启通知使能状态 |
---|---|---|
使用说明
entry/src/main/
|---main
| |---cpp
| | |---types
| | | |---libentry
| | | | |---index.d.ts // 接口导出
| | | | |---oh-package.json5
| | |---NativeNotificationAdaptor.cpp // 调用native接口
| | |---CMakeLists.txt // 编译脚本
| |---ets
| | |---entryability
| | | |---EntryAbility.ets
| | |---pages
| | | |---Index.ets // 首页
| |---resources // 静态资源
|---ohosTest
| |---ets
| | |---tests
| | | |---Ability.test.ets // 自动化测试用例
通过在IDE中创建Native C++工程,在C++代码中定义对外接口为isNotificationEnabled,映射C++接口IsNotificationEnabled。通过获取JS的资源对象,并转化为Native的资源对象,即可调用对外开放的Native接口。在JS侧导入"libentry.so",调用src/main/cpp/type/libentry/index.d.ts中声明的接口。源代码参考:NativeNotificationAdaptor.cpp。其中涉及的相关接口:
接口名 | 描述 |
---|---|
bool OH_Notification_IsNotificationEnabled(void); | 查询当前应用通知使能状态。 |
不涉及
不涉及。
如需单独下载本工程,执行如下命令:
git init
git config core.sparsecheckout true
echo code/BasicFeature/Native/NdkNotification/ > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。