Push Notifications are displayed only if service worker is debugged - asp.net-mvc

I am trying to implement web push notifications in my chrome browser using a .net MVC web application and service workers.
I am able to subscribe to the push service and get the subscription object from web app.
But when try to send a notification message from the server, the notification doesn't get displayed.
But if I debug the service worker by placing a break point inside the push event handler function, the break point is hit and if I step through the code the push notification is displayed.
I am not sure where the problem lies. Please help.

Finally found out what was causing the issue.
I subscribe from my local system, leave the browser open and send notification by connecting to a VM through MSRTC. The reason the notifications didn't get displayed was the MSRTC application was the active program and not my local system.
If I send notification from a different system, my browser receives and displays it.
Thanks for your replies.

Related

web push notification doesn't show if pc is off or sleeping

So I have finally implemented a successfull push notification for my website
however when i push the notification and suppose the reciever's pc is off , or in sleep mode the
gcm returns success but the notification is lost ,it never pops up for that user ...while on the other hand i noticed facebook seems to be doing something that helps it get past this problem .. you see a facebook chrome notification as soon as you open chrome the first thing after a fresh restart ...
does any body have any idea as to how fb gets past this problem ??
If you're using a standard Web Push service (e.g. in Firefox), you need to define a header called 'TTL'.
From the standard (https://datatracker.ietf.org/doc/html/draft-ietf-webpush-protocol-02):
An application server can use the TTL header field to limit the time
that a push message is retained by a push service. The TTL header
field contains a value in seconds that describes how long a push
message is retained by the push service.
If you don't set it, the default is 0.
GCM doesn't support the Web Push standard yet, but it does have a time_to_live option that should achieve the same result: https://developers.google.com/cloud-messaging/concept-options#ttl
EDIT: The Mozilla push service now requires the TTL header: https://blog.mozilla.org/services/2016/02/20/webpushs-new-requirement-ttl-header/.

Refreshing data without push notification

So I have build a chat,
Right one user1 sends text to user2.
user2 gets push notification, if the app is open then using the push notification code I'm re-downloading the data from server.
So my question is, is there any way to reload data without push notification? like find when the content is available and download the data and reload the chat.
I'm pretty new ios programming so I don't know whats is exactly called or any ways to do it without getting a push and running a function.
There are only a couple of ways for a server to reach out to your app. Through push notifications (both silent and normal,) and using a socket. Sockets are more immediate but only work when your app is active in the foreground.
The only other option is for your app to poll the server. IE, for it to call a server outlet every few seconds and ask if there is any new information.

How can I handle unread push notifications in iOS?

I have a iOS 5.1 application that registers to the APNS service to receive notifications. The register is successful and I receive the notifications correctly. The problem comes when I try to handle the notifications.
Once the application is running, the method didReceiveRemoteNotification in the AppDelegate is called correctly and so the notification is handled as intended. This, however, only happens when the application is running on the foreground.
However, when the application is running on the background or is simply stopped, that method is not called. I've read that you should add some lines to the method didFinishLaunchingWithOptions method to obtain the notification from the userInfo dictionary, and handle it. This works just fine, but ONLY when the application is opened by clicking on the notification at the Notification Center. This means that if you open the application by clicking on its badge, or simply by changing context if you were running it on the background, the app never realises that a notification came in. Additionally, if more than one notification was received, we can only handle one of them at once by clicking on the Notification Center, which is a pain :-)
Is there any way to read the pending notifications in the Notification Center? I know there is a way to flush them using the method cancelAllLocalNotifications but I haven't found a way to just read them. And I really need to handle all of them. I thought of implementing a communication protocol with the third-party notification server to retrieve the information again when the application comes to the foreground, but since the information is already in the operating system I would find it strange if it's impossible to access it somehow.
So, does anybody know a way to do it? Thanks in advance.
When a push notification arrives and the user clicks 'cancel', your app has no way to read that push notification again. You have to implement a separate functionality (most probably on server-side) to fetch a list of notifications sent to this device.
For example, if a chat functionality is provided in your app and you send chat messages via push notifications then you should also keep chat messages on the server. If a user clicks 'Cancel' on any push notification then that chat message will not be displayed on the iOS device. In that case when a app comes in foreground later, you make a call to the server and fetch all the past chat messages (sent via push notification).
Ok, So a possible solution would be to have another database table with the messages in with a 'read' flag and a messageID field? Which by default the read flag is NO, then when the app successfully reads this and displays, it updates the flag to YES?
And with only 256 bytes to play with, what sort of ID field length would be necessary?
Edit,
Executed this plan and its working successfully.

Xtify push messages are not received on BlackBerry

I have created an account on Xtify for receiving push messages via BIS on Blackberry. Sample application that ships with Xtify SDK works fine and registration requests' responses are successful(As shown on the sample app screen). Finally it prints to the screen that it is listening for incoming messages. When I send a notification from web console it says "Notifications were sent to blackberry users:". but no push message is received. Also note that I have used BlackBerry server SDK to receive push messages which I was writing for another application and it worked really well.
Since I am sure that the client application works, I tried with this service "http://notify.xtify.com/api/1.2/pn/push" to send push messages programmatically. Still it keeps giving this error whatever the value I put in there. I tried device pin, and other keys too. But still the same error.
Any help?

How does a server notify a mobile application of a state change

lets suppose I have a PHP web service, and I have an iphone app that communicates with it. If the iPhone want info from the web services, it makes an http call to the server ans retrieves information. But how do you do this the other way around, how does would the server notify the the application when some state has changed, and what is the most efficient way to do this?
What you are looking for is Push Notifications. You will need to create a push notification server that will send notifications to your users. http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html

Resources