In this push notifications tutorial, you’ll learn how to send and handle push notifications with actions.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/8164-push-notifications-tutorial-getting-started
In this push notifications tutorial, you’ll learn how to send and handle push notifications with actions.
Hi Keegan,
This article: “Push Notifications tutorial getting started” is just awesome.
It is well resonating with the readers and contain good information. But I feel it could be more helpful for newbies, if you add some more information about what is push notifications?
Just wanted to give you a heads up that I created a article to help new readers. It’s like (What is Push notifications), but more thorough and up to date.
Kindly have a look at it? Thought it will be worthy of mention in your article.
I cant seem to use “[weak self]” in the registerForPushNotificatioons()
In registerForPushNotifications(), insert the following just below the guard and above the call to getNotificationSettings():
The code below is wrong.
// 1
let viewAction = UNNotificationAction(
identifier: Identifiers.viewAction, title: "View",
options: [.foreground])
// 2
let newsCategory = UNNotificationCategory(
identifier: Identifiers.newsCategory, actions: [viewAction],
intentIdentifiers: [], options: [])
Correct Code.
// 1
let viewAction = UNNotificationAction(identifier: viewActionIdentifier, title: "View", options: [.foreground])
// 2
let newsCategory = UNNotificationCategory(identifier: newsCategoryIdentifier, actions: [viewAction], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([newsCategory])
Gave the article a try. It was as an ugly experience )
Why? What’s wrong with it?
@omarthebeginner, what error are you getting when using [weak self]
? Are you sure you’re on Swift 4.2, iOS 12, and Xcode 10?
@zgpeace, there is no viewActionIdentifier
or newsCategoryIdentifier
in the starter project, finished project, or the body of the tutorial. You should be using Identifiers.viewAction
and Identifiers.newsCategory
instead, which come from the Identifiers
enum in the starter project’s AppDelegate.swift.
Is it possible that you’re looking at an older version of the project for this updated tutorial? :]
Let me know if I can help!
@keeganrush Can you please help with this when you get a chance? Thank you - much appreciated! :]
The issue I’m running into doesn’t seem to be covered here. I got as far as: Sending a Push Notification
If you haven’t downloaded the PushNotifications utility yet, now’s the time.
Launch PushNotifications and complete the following steps:
I downloaded the package at the url above, and there isn’t any executable code in there that I could find. So when you say “Launch PushNotifications” I don’t see any way to do that. All that is in the package are a bunch of .js files. I got the token and the certificate file downloaded, but after that I’m lost.
Hi @markddude, have you followed the steps under How to install as mentioned in the instructions above?
The How to install section on the PushNotifications GitHub page directs you to download the latest release. Currently, the latest release is 1.3.0, so download and install PushNotifications-1.3.0.dmg.
Let me know if that helps :]
Yep. That was it. Thanks for your help!
Great article. Just a word of caution for noobs like me - beware of your JSON syntax for the payload of the PushNotification utility. A comma too many or the wrong type of quote marks and it won’t succeed - it will just get stuck indicating it is trying to send but in fact it is stuck.
@cefitzger Thank you for the heads up - much appreciated! :]
This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!