I have used the pushcollector example from blackberry code from github to integrate push notification, I'm receiving notification in my device but with default sound and bell icon. I need to change the default bell icon and sound with the ones that I provide. My device is Dev Alpha B and version is 10.2.1.3061
This is my pushnotfication handler code but it doesnt set the sound or icon. Any help is appreciated
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());
}
}
You must specify them as public assets in bar-descriptor.xml and then use public urls instead of private.
Best way - create separate folder for public assets
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"));