开发者社区 问答 正文

在应用研发平台EMAS上移动推送可以自定义设置音效吗?

在应用研发平台EMAS上移动推送可以自定义设置音效吗?

展开
收起
小小鹿鹿鹿 2023-11-06 16:22:23 73 发布于山西 分享
分享
版权
2 条回答
写回答
取消 提交回答
  • 在线可以,离线不行。此回答来自钉群应用研发平台EMAS开发者交流群。

    2023-11-07 22:43:54 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
  • 可以,设置通知声音
    设置推送通知声音文件路径。注意android 8.0以上需要使用NotificationChannel配置声音。https://help.aliyun.com/document_detail/434666.html?spm=a2c4g.435761.0.i7


    若不调用本接口,默认获取资源ID为R.raw.alicloud_notification_sound的资源文件。

    若没有获取到指定声音文件,取设备设置的消息声音。

    接口定义

    void setNotificationSoundFilePath(String filePath);

    ``` int assignSoundId = getResources().getIdentifier(ASSIGN_NOTIFCE_SOUND, DEFAULT_RES_SOUND_TYPE, PackageName);
    if (assignSoundId != 0) {
    String defaultSoundPath = DEFAULT_RES_PATH_FREFIX + getPackageName() + "/" + assignSoundId;
    mPushService = PushServiceFactory.getCloudPushService();
    mPushService.setNotificationSoundFilePath(defaultSoundPath);
    Log.i(SETTING_NOTICE, "Set notification sound res id to R." + DEFAULT_RES_SOUND_TYPE + "." + ASSIGN_NOTIFCE_SOUND);
    this.appendConsoleText("Set notification sound res id to R." + DEFAULT_RES_SOUND_TYPE + "." + ASSIGN_NOTIFCE_SOUND);
    } else {
    Log.e(SETTING_NOTICE, "Set notification sound path error, R."

                    + DEFAULT_RES_SOUND_TYPE + "." + ASSIGN_NOTIFCE_SOUND + " not found.");
            this.appendConsoleText("Set notification sound path error, R."
                    + DEFAULT_RES_SOUND_TYPE + "." + ASSIGN_NOTIFCE_SOUND + " not found.");
        }
    

    ```

    2023-11-06 16:55:47 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等