Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom
Accepted Solution

HELP Notification Problems in QML

[ Edited ]

I don't know why my custom sound and icon doesn't work. I have verified my sound and icons are really in the exact location and they're valid. Smiley Sad

 

//imported this import bb.platform 1.2 // I am running it to my device with 10.2 OS
//I've also added the permissions and the proper library in the pro file

Notification { id: theNotification soundUrl: "asset:///sounds/ios.wav" iconUrl: "asset:///images/icon.png" title: "Test" body: "Test" }

then I call this in a button theNotification.notify();

 

Also how can I keep adding notifications? When it already added a notification in the hub, it cannot add another one again and nothing happens.  Smiley Sad

 

Also is there a way to disable Default Sound Notifications?

 

I hope there's a solution to this little problem.

Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: HELP Notification Problems in QML

I don't have a definitive answer to your first question but the sample code I saw in the docs for Notification don't use the asset:/// URI for the sound and icon URLs, they use file:/// instead. Try converting the URIs to use file:///. If have discussed how to access the assets path in other threads.

 

As for the second part of your question, I suspect the reason you can only post one notification is that you keep posting the same one every time, which just updates the one already there. I believe each notification has to be a separate instance to show more than once in the Hub. Try putting the notification inside a ComponentDefinition, like this:

 

attachedObjects: [
   ComponentDefinition {
      id: notifyDef
      Notification {
         id: theNotification
         soundUrl: "asset:///sounds/ios.wav"
         iconUrl: "asset:///images/icon.png"
         title: "Test"
         body: "Test"
      }
   }
]

Then when you need to post a notification you can do this:

 

var notification = notifyDef.createObject();
notification.notify();

This way you are posting a completely new Notification, not just changing the attributes of an existing one.


nemoryoliver wrote:

I don't know why my custom sound and icon doesn't work. I have verified my sound and icons are really in the exact location and they're valid. Smiley Sad

 

//imported this import bb.platform 1.2 // I am running it to my device with 10.2 OS
//I've also added the permissions and the proper library in the pro file

Notification { id: theNotification soundUrl: "asset:///sounds/ios.wav" iconUrl: "asset:///images/icon.png" title: "Test" body: "Test" }

then I call this in a button theNotification.notify();

 

Also how can I keep adding notifications? When it already added a notification in the hub, it cannot add another one again and nothing happens.  Smiley Sad

 

Also is there a way to disable Default Sound Notifications?

 

I hope there's a solution to this little problem.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom

Re: HELP Notification Problems in QML

[ Edited ]

Hi, i tried your 2nd suggestion and didn't worked at all. no errors and no notificaitons were emitted.

I just used C++ and works perfectly. Thanks so much! Smiley Happy

 

I just built a function

 

void ApplicationUI::notify(QString title, QString body)
{
	Notification* notification = new Notification();
	notification->setTitle(title);
	notification->setBody(body);
	notification->notify();
}

 Then call it whenever I need to post a Hub Notification. 

Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: HELP Notification Problems in QML

Not sure if you mean that my suggestion was helpful or if you figured out another way to fix it. Either way, if you are ok now then please mark this thread as solved.


nemoryoliver wrote:
Hi, i tried your 2nd suggestion and didn't worked at all. no errors and no notificaitons were emitted.

I just used C++ and works perfectly. Thanks so much! Smiley Happy





Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom

Re: HELP Notification Problems in QML

Sorry. I mean. your suggestions didn't worked. And I found my own solution that I just used C++ code to make notifications.

Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: HELP Notification Problems in QML

Ok, just flag your own last post as the solution so other readers know this thread is closed. Also, it would be helpful to others if you posted details of how you fixed it.


nemoryoliver wrote:

Sorry. I mean. your suggestions didn't worked. And I found my own solution that I just used C++ code to make notifications.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom

Re: HELP Notification Problems in QML

Just did. Thanks Smiley Happy
Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: HELP Notification Problems in QML

Thanks for posting your solution. I want to point out that the key here is basically what I suggested... stop reusing the same Notification over and over. Moving it to C++ was incidental. By using new each time you are posting a unique notification so the Hub will display each one seperately. If you had created a single instance of Notification and sent it to the hub multiple times, you would have had the same problem as before since the Hub would just keep updating the single notification with the new parameters.


nemoryoliver wrote:

Hi, i tried your 2nd suggestion and didn't worked at all. no errors and no notificaitons were emitted.

I just used C++ and works perfectly. Thanks so much! Smiley Happy

 

I just built a function

 

void ApplicationUI::notify(QString title, QString body)
{
	Notification* notification = new Notification();
	notification->setTitle(title);
	notification->setBody(body);
	notification->notify();
}

 Then call it whenever I need to post a Hub Notification. 






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom

Re: HELP Notification Problems in QML

right. I forgot. It really needs a new instance of a notification object to be unique. but making a notificaiton object using the component definition didn't worked. but creating a new object instance in c++ does work.