为 blackberry cascades 10 自定义推送通知声音和图标

Customize push notification sound and icon for blackberry cascades 10

我使用了来自 github 的黑莓代码中的 pushcollector 示例来集成推送通知,我在我的设备中收到通知,但带有默认的声音和铃声图标。我需要用我提供的更改默认的铃铛图标和声音。我的设备是 Dev Alpha B,版本是 10.2.1.3061

这是我的推送通知处理程序代码,但它没有设置声音或图标。感谢任何帮助

void ApplicationUI::pushNotificationHandler(bb::network::PushPayload &pushPayload)
{
    qDebug() << "Received push pushNotificationHandler";

    PushHistoryItem pushHistoryItem(pushPayload.id());

    if (m_pushNotificationService.checkForDuplicatePush(pushHistoryItem)) {
        qWarning() << QString("Duplicate push was found with ID: %0.").arg(pushPayload.id());

        return;
    }

    Push push(pushPayload);
    push.setSeqNum(m_pushNotificationService.savePush(push));

    Notification *notification = new Notification(NOTIFICATION_PREFIX + QString::number(push.seqNum()),this);
    notification->setTitle("Yo");


    PlatformInfo pkinfo;
            QString osVersion=pkinfo.osVersion();
            qDebug() <<"OS full:"<<osVersion;
            osVersion.resize(4);
            qDebug() <<"OS:"<<osVersion;
            float versionValue=10.2;

           if(osVersion.toFloat()>=versionValue)
           {
               qDebug() <<"Notification set:";
               notification->setIconUrl(QUrl("file://" + QDir::currentPath() + "/app/native/assets/Images/customIcon.png"));
               notification->setSoundUrl(QUrl("file://" + QDir::currentPath() + "/app/native/assets/Sounds/customSound.mp3"));
           }
           else
           {
               qDebug() <<"Notification unset OS version is:"<<osVersion.toFloat();
           }

    notification->setBody(QString("New %0 push received").arg(push.fileExtension()));

    InvokeRequest invokeRequest;
    invokeRequest.setTarget(INVOKE_TARGET_KEY_OPEN);
    invokeRequest.setAction(BB_OPEN_INVOCATION_ACTION);
    invokeRequest.setMimeType("text/plain");
    invokeRequest.setData(QByteArray::number(push.seqNum()));
    notification->setInvokeRequest(invokeRequest);
    notification->notify();

    m_model->insert(push.toMap());
    if (pushPayload.isAckRequired()) {
        m_pushNotificationService.acceptPush(pushPayload.id());
    }

}

您必须在 bar-descriptor.xml 中将它们指定为 public 资产,然后使用 public 网址而不是私有网址。

最佳方式 - 为 public 资产创建单独的文件夹

bar-descriptor.xml

<asset path="assets">assets</asset>
<asset path="public" public="true">.</asset>

C++

notification->setIconUrl(QUrl("file://" + QDir::currentPath() + "/app/public/Images/customIcon.png"));
notification->setSoundUrl(QUrl("file://" + QDir::currentPath() + "/app/public/Sounds/customSound.mp3"));