Setting up remote notifications

I have obtained everything I need from apple, and have setup the server correctly (thank you Xojo for the example app), but now I can’t make progress in the iOS project.

Calling: MobileNotifications.RegisteredForRemoteNotifications

causes an example with the message: Notifications were not added to this project.

I believe I’ve setup the capabilities correctly in the project.

What might I be missing?

I’m hoping that you’ve gotten an answer from Jason by now but for the sake of completeness, you need to request authorization to use notifications before you can register for remote notifications or even check.

In the open event of the app, make the request and then in the event that indicates success, that’s when you request a remote notification token. Just to be clear, you should probably request a token each time your app is launched. Apple’s docs say that the token can change so you may need to store a new token for a user periodically.

Jason was very helpful, and I got past that.
Now it’s complaining:

“no valid “apt-environment” entitlement string found for application”

I’m trying to figure out how to add that, but I’m not having much luck.
I rebuilt my certificates for the app in the Apple Developer site, and included these entitlements. Still no go. I need to get them into Xojo somehow.

It might have changed now, but about 2-3 years ago I would create the entitlements needed for notifications in XCode using the same bundle ID etc as the Xojo app then copy the entitlements file to the Xojo project. I don’t remember how to do that anymore unfortunately but I know that’s what I had to do a while back.

I tried that.
I’m getting a very specific error that I’ve sent to the Xojo team (it includes stuff I can’t share publicly).

When it’s sorted I’ll share findings here.

1 Like

Make sure the Push Notifications item is enabled in the iOS capabilities tab. That’s what adds that item when you build.

I’ve got a sample project here that I use for testing new iOS features. I’ll trim that down and make a sample for you that has all the necessary pieces.

It is.

That might help.
Is there anything special I have to do when setting up the identifier in the developer site?

I tried adding the notification there and it didn’t work. Took it back out, and I still cannot compile if I have the push notification switch on in Xojo.

I get this error message (followed by a lot more)

Did you have to add an entitlement to the project?

The operation couldn’t be completed. objc[17160]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1f53e5160) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1143402b8). One of the two will be used. Which one is undefined.

objc[17160]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1f53e51b0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x114340308). One of the two will be used. Which one is undefined.

2021-08-05 23:19:49.499 xcodebuild[17160:23034839] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path ‘/var/folders/fr/8zp1lr_x1gvdjk1xm1ly7q6c0000gn/T/myColor_2021-08-05_23-19-49.499.xcdistributionlogs’.

error: exportArchive: Provisioning profile “CMCDistribution” doesn’t support the Push Notifications capability.

You will need to make sure that Push Notifications are enabled in the Provisioning Profile for the app itself in your Apple Developer portal. Also, make sure that the bundle identifier in your app exactly matches that of the provisioning profile.

No. As I said before, enabling Push Notifications in the iOS Capabilities on the Advanced tab of the iOS build target will do that for you.

Here’s the sample project. In it, I’ve added non-operative methods to the NotificationCenter which have detailed explanations of what each one is for, but the app itself does send and receive notifications, both local and remote. You’ll need to update the bundle identifier to match the one that you are using if you want to test this app.

FYI, I’m not sure how you got AMSupportURLSession into your app, but it’s a private Apple framework and it’s unlikely that you’ll get by the “app police” with that in your project.

Sample Project

I’m assuming that this is because I’m allowing users to connect to arbitrary servers, some of which could be non https.

It’s working, and I can pull it out and enforce secure servers before I launch.

Downloading now. Thanks.

I get the same error. It must have something to do with the provisioning profile and identifier.
I’ll rebuild those again.

I’ve updated the identifier, and regenerated everything else from the developer portal.
WIth your example, I can get it to run on my phone only if I don’t build for App Store.
It does register for remote notification (I get a token). But with the Xojo cloud example app, I cannot get the iOS app to receive a single remote notification. And I double checked that all the required parameters were right on the server.

Can you verify everting that had to be selected in the identifier’s capabilities?

Well the good news is that I think we’ve narrowed this down to your Apple dev stuff because I know that the sample works here.

I’ll check all of the profiles again when I get to my desk and make a definitive list.

Just to be clear, you’re not using any wildcard app identifiers correct?

No wildcard.
Thanks, Greg.

Ok, make sure that you’ve created a push notification certificate for your app which supports both Sandbox and Production if you’ll be using Xojo Cloud:

Next, make sure that your distribution profile includes Push Notifications:

You’re also going to need a Key for your app to access the Apple Push Notification service:


All of these things need to use the same application identifier

1 Like

Hi Greg,

Yes, I’ve done all these things.
I’ve also read up on the order of operations and I know the profiles have to be created after the other things are in place.

I’m going to take a second shot at remaking all profiles etc later today and I’ll share back any learnings I come up with.

I’m sure it’s something trivial, but so hard to figure out.

1 Like