Closed AlphaJian closed 8 years ago
You may need to set priority
to "high"
for the notifications to work while the app is in the background. This is hard to debug without you showing any code, though :smile:
@hypesystem .So below is my server code:
let message = new gcm.Message()
message.addData('title', 'new message')
message.addData('message', 'message you have a task to do')
message.addData('priority', 'high')
let regTokens = ['xxxx']
// Set up the sender with you API key
let sender = new gcm.Sender('xxxxxx')
console.log(message)
// Now the sender can be used to send messages
sender.send(message, { registrationTokens: regTokens}, function(err, response) {
if (err) console.error(err)
else console.log(response)
})
And in my Xcode, this function
func application( application: UIApplication,
didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){}
really receive the message, even in back ground. But the point is, as normal app, they can receive notification in system notification center. But mine is not working.
I am not sure I understand exactly what is not working. Do you think you could try and explain it in more detail?
@hypesystem what he means is, he can receive the message in the function didReceiveRemoteNotification from the client but no notification comes and we can print out the message from the userInfo. We can trigger the notification manually but as what it should be is the notification center of IOS will send the system notification, there is no need to trigger it, the problem might be the notification center can not recognize the notification?
Ah! In his code he is using addData
to set data on the message. If you want a notification to show up automatically, you need to set the notification
field (with addNotification
). Follow the instructions in the README :smile:
I am facing the same issue even after adding notification. Please tell what should I send in notification to make it work.
Thanks!
@piyushsf it's hard to help unless you show some code :-) what have you tried? how does your code look?
It is working fine as there was some issue at my end. Thanks for the help :)
I am closing this issue for lack of response. If you need more help, please feel free to take it up again :-)
I finish integrating GCM into iOS. And the delegate "didReceiveRemoteNotification" can also receive notification. But my issue is when app is in background, how can device receive system push notification as other app?