Mismatched Bundle ID (Sandbox) in OneSignal - ios

I'm trying to send PN to my iOS App.
I followed the standard steps, i.e.:
create new app and upload the development and distribution(sandbox) certificates
put the App id in my project: OneSignal.initWithLaunchOptions(launchOptions, appId:"myAppID")
create new template
send a message
When I sent the PN I got "send message successfully" green message, but after a while I got a warning when I clicked on it I directed to App Settings page and the warning is:
and I didn't receive any PN!!
I checked my bundle ID in my project and it's 100% matched to the uploaded certificates.
Anyone faced like this problem when trying to use OneSignal for PN?
Please help.
Thanks.

This problem happens when your application is built with a Provisioning Profile for a Bundle ID that does not match the Bundle ID of the push certificate you uploaded to OneSignal.
It is possible that you have created several builds of your application, some with the correct bundle id and some with an incorrect one. As a result you may have subscribed devices in OneSignal that are linked to different bundle ids.
If you are able to receive notifications with the latest build of your application then you can probably ignore this error. If all of the iOS notifications you send show up as "Invalid", then you must either upload a new push certificate with the correct bundle id, or build your app with a provisioning profile that matches your push certificate's bundle id.

I got this warning on a few of my failed messages that I triggered from Zapier. I verified my Bundle ID and they are exactly the same, and I was getting other notifications just fine. As #gdeglin said I'm going to ignore this warning for now, as it doesn't seem to point an issue at this point of time. If you find any other answer to this please share, I'm sure others are facing similar issues as well.

Related

Missing Push Notification Entitlement, even with aps-environment entitlement set. iOS and Testflight

Good morning!
I am working on getting my app to receive push notifications from Firebase cloud messaging. when I add my build to testflight, I get a warning email with the error code: ITMS-90078: Missing Push Notification Entitlement, I am allowing xcode to manage my profile, which has the aps-environment entitlement and the capability for push notifications, and a development signing certificate, as you can see in this screenshot from xcode:
Luckily, this is just a warning, so I can still push this build to my testflight testers, but they do not receive push notifications. I can confirm that firebase cloud messaging is generating the device messaging token, and it is storing in my firebase database just fine, so I assume this is not the issue.
I have also confirmed that I have a Production Apple Push notification SSL cert assigned to this bundle ID, as shown here:
After I took this screenshot, I also tried adding a development SSL cert, but the problem persists.
I have found a number of other posts on apple dev forums and here on Stack exchange, but most are fron over 4 years ago and no longer appear relevant. Example: Missing Push Notification Entitlement warning
What am I missing? Thank you for your time and help in advance!
UPDATE
I have now also attempted the to fix this by using a provisioning profile I set up, rather than allowing xcode to manage it for me. It is an "App Store Distribution" Profile.
Same issue, getting the same email error, and any installed applications do not receive push notifications. Any suggestions? Thanks!
After a multi - hour debug session with a friend of mine that is better versed in Apple processes than I am, we managed to figure out the issue. Everything was set up correctly... all my certs were in line, all of the profiles and Bundle IDs matched, everything looked good. The issue was for some reason, xcode was displaying all of my certs from appstoreconnect and developer.apple.com, but it was not including a local entitlements file with the binary that ultimately got uploaded to app store connect, which drew the error, and ultimately prevented push notifications from working. The fix was simple... just click "+ capability" next to "all" in signing and capabilities, search for and add push notifications, and bingo! This adds the proper entitlements to my binary, which then look for the certs in app store connect. This now uploads without the error message and push notifications on any installs from this new build starting working immediately. I hope this helps someone, someday! Apple, please make this more straightforward, or don't let xcode lie about its certs!

InvalidApnsCredential while certificates are valid

I'm trying to send a message to my push notification test app. It's been working in proof of concept several weeks ago on the same application but not anymore.
I get a failure: InvalidApnsCredential and Firebase tell us : "A message targeted to an iOS device could not be sent because the required APNs SSL certificate was not uploaded or has expired. Check the validity of your development and production certificates"
But when I check in my firebase console, it tells me that dev and prod certificate will be valid for 9 more months.
What else could be causing this message?
In case if others are also facing the issue here are few tips:
Whenever you are stuck with notification issues try sending a push via the GUI console that firebase provide to send notifications
If your live app at Appstore is not receiving push notification but is receiving notification only when running via Xcode then you have not uploaded the production certificate to the firebase console
If you have uploaded both production and development certificates and still notifications are not received then download the latest certificates and upload them again to the firebase console
Adding Team id in Firebase worked for me.
Firebase console -> General -> select your app -> Add TEAM ID
You can find team ID in Apple developer portal :
https://developer.apple.com/account/#/membership
This might pain you to hear, but it seems that the Firebase Cloud Messaging system doesn't like dashes in the bundleID. I had something alongs of my.app.bundle-y and I was receiving InvalidAPNSCredential message on postman... I eventually tried changing my bundle id to my.app.bundle when all else failed, and notifications started coming through.
This is pretty severe change, and only really reasonable if the app is not yet deployed.
If all else fails and you have a dash in your bundle id, then maybe give this a go.
In the case of uploading a .p8 file (APNs auth key), adding proper Key ID worked for me.
When you download the .p8 file from Apple. The filename will be in format AuthKey_XXXXXXXXXX.p8. The 10 digit(marked XXXXXXXXXX after the AuthKey_) is the Key ID you need to add.please refer to the image
I had this issue and was struggling to find a solution even when my APNs token were up to date and etc. I was testing on android before IOS and on the POST method to https://iid.googleapis.com/iid i left "application": com.android name instead of IOS bundle ID. just a stupid error on my side.
in my case I was uploading .p8 key with wrong key id duoble check your "APNs Authentication Key" and make sure u have the right file with the right Key ID
and team ID
The Xcode "Bundle Identifier" must match the one configured in Firebase.
In Firebase:
Project Settings > Your Apps > Apple Apps
In Xcode:
Your project > Targets > General tab > Bundle Identifier
In my case, The Apn .p8 file had been deleted from the Firebase console (and I don't know why! :| )
I had it before and just upload it and the problem was solved.
but if you don't have it, you can create a new one from the
Apple developer account -> Certificates -> Keys -> Add new key and check
Apple Push Notifications service (APNs) from the services, then download it and upload in
Firebase -> App setting -> Cloud Messaging -> Apple app configuration -> APNs Authentication Key

Please correct and re-submit. An App ID with Identifier 'com.brs.paysrc' (example) is not available. Please enter a different string

I have an existing app with bundle identifier com.brs.paysrc example and the app is live on store. It was created using a wildcard app id. Now i want to enable push notifications for this app. So i tried to create a new app id with b uncle identifier as com.brs.paysrc but it give some an error saying There were errors in the data supplied. Please correct and re-submit. An App ID with Identifier 'com.brs.paysrc' (example) is not available. Please enter a different string.
(I'm not sure if this'll help you...)
I had the same issue with an app our company has in the App Store.
The reason was because we have both a Developer Program (so we're allowed to submit an App onto the App Store) and an Enterprise Program (so I can make in-house copies of the app).
Our Bundle ID was registered under the Developer Program, but I had logged into the Apple Developer website and had chosen the Enterprise Program group.
In the Apple Developers website, the Identifies\App IDs didn't show our Bundle ID, because it was actually registered under our Developer Program... but, of course, it still refused to let me create the Bundle ID a second time, and, as usual, the error message gave no clue as to what the problem was.
I really hate the whole Certificates/Provisioning Profile stuff with Apple. Their error handling/reporting, when you get something wrong, is a farce. And it'll happily let you create non-working apps, deploy them to a device, then report a "Your app could not be installed at this time" when things go wrong.
Even yesterday, when I was ready to deploy a new version of the App to the App Store, I could create an Archive, the Validate said it was all fine, but then when I submitted it, it reported 3 errors in my .plist file.
Oh, and remember that your Bundle ID is stored in the .plist file and in the settings:
Make sure this Bundle ID is correct in both places!
(Sigh.)
You might have clicked it twice (I did). Check here, to see if your id is there: https://developer.apple.com/account/ios/identifier/bundle
Please give unique bundle ID, it will resolve your problem. Sometimes the same bundle ID is already used by another app. Hence this issue occurs. Try with different bundle ID it will resolve your problem.

Missing Push Notification Entitlement for iOS app

I've just uploaded an app to iTunes Connect and got the "Missing Push Notification Entitlement" warning from Apple. My app does not use any API related to push notifications. The warning also included that I do not have the aps-environment entitlement. How do I get rid of this warning? I tried disabling push notifications in the member center and in Xcode (I created a preprocessor macro DISABLE_PUSH_NOTIFICATIONS=1) and still no luck.
EDIT:
I used grep in my project directory to search for couple of strings that could cause this issue. Grep matched the string
"registerForRemoteNotificationTypes"
in
./myProject.xcodeproj/project.xcworkspace/xcuserdata/myUser.xcuserdatad/UserInterfaceState.xcuserstate
I have no idea whether removing the string from this file will change anything because I am unable to upload the app to TestFlight at the moment. I will be thankful if someone has the same issue and tries to fix it by removing the string found by grep (if it's a good idea to edit .xcuserstate files...)
Try re-create distribution provisioning profile and double check that you do NOT include push notification into list of entitlements
Enable push notification in your bundle Id and recreate provisioning profile .This things work for me.

iOS: Production push notifications, Invalid token from APNS server

My app is now available in the app store, so I've downloaded it to my device. The push notifications were working fine during development. I am using JavaPNS to send out the notifications, and I have switch it to point to Apple's production servers.
However, I'm now getting an Invalid Token error back from the APNS servers.
I have the Archive scheme set to "Release", and I have Release set to use this distribution profile:
Inside that provisioning file, you can see that I have the environment set correctly:
Yet I still get the error. When I look in my database, I think the device token the app is returning to me is the same as the development one, so that could be the problem. But I don't know why it would be returning that, given that the app is signed correctly. This is a device I also used for testing, could that be a problem? Any other ideas about what's happening here?
Thanks!
EDIT: I'm not storing a token in my code, Eran's answer suggests that the only other possibilities are an old token in my database, or the app not being signed by a production profile. I'm cleared my database, so I know it's not the former, and as for the latter, I don't see how that could be the case, since I only have one distribution profile, and as I've shown above, it has the "aps-environment" key set correctly. XCode wouldn't even let me use a development profile for app store submission, would it? A few other possibilities:
Is it possible that something being wrong with key I'm sending with my notifications could cause "Invalid Token"? If so, can I regenerate this key for my existing profiles?
Isn't there another provisioning profile contained in the AppID for the purposes of push notifications? Could a problem with that cause the invalid token error?
I re-downloaded the push production certificate and exported it from the keychain as .p12. This seems to have solved the problem. It seems strange though that a bad private key was giving me the "Invalid Token" error.
The device token for production is different than the development one, so if you send a development token to production APNS servers (or vica versa), that's the cause of the problem.
It's possible you didn't remove the development device token from your server when you switched to production.
Or if you are getting the development token from your production app, then either the app is returning a locally stored device token (which you may have stored on your device during development) instead of asking Apple to get a new one, or (if you do ask Apple for a current token and still get the development token) your app is not signed with the production provisioning profile.
MyApp is an iOS app that sends and receives Push Notifications MyApp-to-MyApp using APN token IDs fetched from a database that is kept updated by each MyApp at logon. The Push Notifications are sent by MyApp using the NWPusher framework API.
As long as the project was run in Developer (Debug) mode, sent and received Push Notifications worked perfectly. But, in Production mode, sending Push Notifications would not work.
I went back and completely recreated my AppID, SSL certificates, provisions, etc., but to no avail. Next I used the NWPusher MacOS Pusher app to experiment with sending Push Notifications to MyApp. I configured Pusher to send a Push Notification (to the tokenID of an Ad Hoc distribution of MyApp) with MyApp’s Production SSL certificate, and got the following message in the Pusher log: "Notification error: APN invalid token".
I next noticed that Pusher had a checkbox option “Should use sandbox environment” checked. I unchecked the option and tried it again. This time the Push Notification was sent and then received by the target phone without any errors. This led me to take another look at the NWPusher.connect call:
Swift:
let pusher:NWPusher? = try? NWPusher.connect(withPKCS12Data: pkcs12! as Data, password:APNS_Certificate_Password,environment:NWEnvironment(rawValue:1)!)
which has an environment argument NWEnvironment enum with possible values 0=none, 1=sandbox, 2=production, 3=auto.
Changing rawValue:1 (develop sandbox) to rawValue:2 (production) fixed the problem: Production Push Notifications now work without errors.
xCode 8.0
I had "invalid token" error the after installing of xCode 8.0.
The issue was found here: Project Navigator -> select project (topmost item) -> select project name in Targets menu -> choose Capabilities in top menu -> look at PUSH Notifications section -> click "Fix issue"
Found the root cause for this issue, it is because of bad private key. To resolve this issue just generate a .p12 certificate with .pem . For creating the p12 file with .pem file please follow the below method
Under ios App Bundle IDs menu in https://developer.apple.com/account/ios/identifier/bundle
click the id of your app if in production, add a new certificate if the old one has expired.
Ensure your App Bundle ID com.myapp.mycom matches your Certificate Name com.myapp.mycom

Resources