Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Silent notifications not working on iOS? #438

Closed
thesauravmitra opened this issue Nov 6, 2019 · 2 comments
Closed

Silent notifications not working on iOS? #438

thesauravmitra opened this issue Nov 6, 2019 · 2 comments

Comments

@thesauravmitra
Copy link

thesauravmitra commented Nov 6, 2019

Hi, I've recently switched to using gorush to deliver notifications to my app.

I am checking if my app is receiving notifications (in my case, while the app is in the foreground) by implementing the following in AppDelegate.swift:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    print("USER INFO", userInfo)
    completionHandler(.noData)
}

If I don't set the delegate function userNotificationCenter(_, willPresent: withCompletionHandler:), then all remote notifications will be processed in the AppDelegate function.

If I send the following data, the function is not called, implying that the notification was not received:

{
    "notifications": [
        {
            "tokens": ["my_token"],
            "data": {"custom_data_field": 3},
            "platform": 1,
            "topic": "my_topic",
            "development": true, 
            "content_available": true
        }
    ]
}

If I add a title: "my_title" to the notification, with or without the content_available field, the function is called, which means the notification has most definitely been received.

This seems to imply that silent notifications are not being delivered correctly. Any ideas?

@slimus
Copy link
Contributor

slimus commented Feb 25, 2020

@thesauravmitra
Why do you think that silent notifications are not being delivered correctly?
I read this article https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app and it seems all is ok

@slimus
Copy link
Contributor

slimus commented Apr 22, 2020

@appleboy close this issue?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants