IOS Firebase Cloud Messaging "InvalidApnsCredential" - ios

I'm trying to add push notifications to my Ionic app using FCM and running into issues with IOS, (android works as intended). Before marking this as a duplicate, Ive tried the solutions from the other similar questions but it didnt help.
In the firebase console I have set the team Id, App id as well as uploded the APNS p5 generated by apple to my console as well.
And finally, the latest plist file to my app's root. From xcode, I can see the certificate has push notifications enabled too and the app asks for that permission for it as well. After that I got the device notification id and tested it via the console as well as the api endpoint but I keep getting the "InvalidApnsCredential" error. I did the steps from few other questions from here but had no luck. I cant seem to get it working, below is a few snippets of my code
this.platform.ready().then(() => {
this.fcmService.getToken().then(resp=>{
this.httpService.sendToken(resp)
.subscribe(res => {
console.log(res)
});
console.log(resp)
});
});
And the body of the api post request
Endpoint: https://fcm.googleapis.com/fcm/send
Body:
{
"notification":{
"title":"Ionic 4 Notification",
"body":"This notification sent from POSTMAN using Firebase HTTP protocol",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
},
"data":{
"landing_page":"second",
"price":"$3,000.00"
},
"to":"IOS_DEVICE_NOTIFICATION_ID",
"priority":"high",
"restricted_package_name":""
}
The code and api endpoint seems correct as it works for Android. Is there anything im missing to get it working?

So, this may not be exactly the answer that youre looking for but, for me everything worked fine after i recreated the app on ios.
Common issues include
- trying to send a notification before the client gives premission
- sending notifications using older IDs (yes they change sometimes)
- package name mismatch between your app and ios app

Following are the reasons of "InvalidApnsCredential":
Maybe bundle id changed [find in code where bundle id name mismatch, change it]
APN keys expired [ update it in firebase console]
Find out the exact error from this link enter link description here that you got.

In my case, I forgot to enter and upload the APNs Authentication Key in the firebase console. Please go to the
Cloud Messaging -> Apple app configuration
Add AuthKey File(.p8), Key Id & Team ID
Check the image below. And it's working fine for me.
Make sure Team ID is added in the SDK setup and configuration.

Related

get Blank Response Subscription Status URL IAP from Apple server, Status Update Notifications, statusUpdateNotification

Status Update Notifications, statusUpdateNotification
I set Subscription Status URL in my APP in iTunes account like https://www.xxxxxx.xx/iospushnotification.php
I also successfully tested nscurl --ats-diagnostics https://www.xxxxxx.xx/iospushnotification.php
I also implemented php code in iospushnotification.php file to get JSON response
I purchased successfully Auto renewal Subscriptions Sandbox but I did not get any Status Update Notifications I get blank [] JSON response from apple server to my server.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html#//apple_ref/doc/uid/TP40008267-CH7-SW6
if anyone still cares 2 years later, I found a solution, assuming you're using PHP.
from the stackoverflow post Receive JSON POST with PHP we need to do something like this:
$appleData = file_get_contents('php://input');
then try to json_decode($appleData) from there.
(I've never had to do something so weird to get POST data before, but I've mostly used frameworks before; unfortunately, I do not currently have that luxury...)

Firebase for iOS - console stuck in Not configured for Cloud Messaging

I already configured tons of apps for APNS in Firebase and it was always painless. Today I'm tring to configure another one which I already implemented the entire SDK for Messaging, added the GoogleService-Info.plist, enabled the bundle ID for Push Notifications, runned the app with Firebase smoothly in a device.
But the Firebase console configuration screen for Notifications doesn't let me upload my certificates or my APNs Auth Key (which I already have too).
The upload buttons are missing, the "fields" are not doing anything, I already tried switching browsers and even switching the computer (Windows based).
I'm working with a mac, tried Google Chrome, tried Safari, tried Chrome for Windows (in another computer) and nothing changes... I'm stuck in this screen.
EDIT: I inspected the console webpage and saw that my browser is getting 404 from Firebase server connection getApnsAuthKey:
{
"error": {
"code": 404,
"message": "APNS cert not found for requested project and bundle ID",
"status": "NOT_FOUND",
"details": [
{
"#type": "type.googleapis.com/google.internal.firebase.v1.ErrorCode"
}
]
}
}
I have the same problem with Firebase Console. It looks like temporary issue on server side. So here is my solution (it works for me):
Open the https://console.firebase.google.com/project/your-project/settings/cloudmessaging/
Press cmd+option+i in Chrome to open Dev Tools
Using Dev Tools inspect grey boxes and find <button/> "Upload" element
Remove display: none !important; rule from this <button/>
Also disable visibility: hidden; property of button's parent div element
After that you can upload certificates or APNS key as it should be in normal.
The Firebase may be updated with new UI -> new elements at this time (November 2017).
Inspect the Upload button
Remove disabled="disabled" attributed in the button tag
Upload button is enabled!
In my case, the reason the Upload button was disabled was not shown in the UI, but was visible when inspecting the elements.
You must be an owner to upload an APNs auth key
My permissions are that of Editor, seems you need to be Owner to upload.

Amazon Pinpoint Message Not Delivered In IOS

I have been trying to use Amazon Pinpoint to run push notification campaign for iOS using the sample app to no avail. For Android, it was successful though. I tried pushing using APNS directly and Amazon SNS, both were successful.
I am suspecting that there are some certification issues relating to iOS. I used this documentation guide to obtain the .p12 certificate to upload to 'Manage - Channel' section of the Pinpoint interface and also for Amazon SNS.
http://docs.aws.amazon.com/mobile-hub/latest/developerguide/ios-appid-setup.html
The devices were detected but the messages weren't delivered to iOS. In the screenshot below, the delivered count is for Android device (2 iOS device, 1 Android).
Any help will be greatly appreciated. Thanks!!
Could this be because your cert is a "dev" or "APNS Sandbox" cert?
If so, sending to APNS Sandbox is not currently supported via the Amazon Pinpoint Console.
To do so using the CLI (or any SDK) is relatively straightforward but requires some shell knowledge.
You'll first want to register your APNS_SANDBOX channel
## Assuming you have your cert and key in the following files
MY_CERT=$(cat my-cert.ct)
MY_KEY=$(cat my-key.pk)
aws pinpoint update-apns-sandbox-channel --apns-sandbox-channel-request Certificate=$MY_CERT,Enabled=true,PrivateKey=$MY_KEY
Then you can send to any address directly using the direct send API
aws pinpoint send-messages --message-request "{
\"Addresses\": {
\"YOUR_SANDBOX_TOKEN_HERE\": {
\"ChannelType\": \"APNS_SANDBOX\"
}
},
\"MessageConfiguration\": {
\"APNSMessage\": {
\"Action\": \"OPEN_APP\",
\"Body\": \"Body of message\",
\"Title\": \"Subject\"
}
}
}"

Can't send push notification to single iOS user on Azure Mobile Services

I've set up my mobile service on Azure and uploaded the development certificate with push notification permissions. I'm using mono touch to the get the device token from the app and sending that up with a request. When the item is inserted I want to send a push to the client but in the logs I keep getting this error
{ [Error: 400 - Invalid expression: '568d4f52 615ee9.......
where the expression is my device token. If I go to the table I can see that the device token matches the one generated in the iOS app. I did upgrade the mobile service to the enhanced push but can't find any examples of how to push to a single user. In my code I have
request.execute();
push.apns.send(item.pushNotificationHandle, {
alert : 'testing',
payload: { text1: 'inner text' }
}, {
error: function(error){
console.error(error);
}
});
The docs on the Azure site seem to be getting pretty stale so I've no idea where the error is and how it should be different. Looking at their server reference docs here I'm not sure why this is failing
http://msdn.microsoft.com/en-US/library/azure/jj839711.aspx#send
Does anyone have any experience with this? I have logged out "item.pushNotificationHandle" and it is a string as expected (matches in the table)
Thanks for pointing out the documentation which has not yet been updated.
Please see this documentation for an almost accurate enhanced push version of push.apns: http://dl.windowsazure.com/nodedocs/ApnsService.html
What you can see is that the send method's first member is tags.
To use enhanced push to target a single user, you should add a unique id for that user the user's tags. Then you send the notification to that specific user's tag. (This feature can also be used for sending to a subset group of users.)

redirect_uri_mismatch Unity Google API on iOS

I created an app in Unity with Google Play Leaderboard support. I could easily make it work on Android, then I moved to OSX to build it for iPhone too.
First I got a problem, that Apple won't accept any bundle identifier with the '_' character in it, but my Android app bundle identifier had 2 of them...
However I found out, that in the Google Developer Console I can link another app to my app (to use the same Leaderboard) for iOS too, so I was quite happy. Unfortunately this doesn't seem to work. I get the *redirect_uri_mismatch* error message every time I try to log in.
On Android I used the UnityGPGPlugin but as it didn't work for me on iOS, I tried the PlayGameServices too. In UnityGPGPlugin I could set only the Application ID, so I thought that's why it is not working. In the PlayGameServices plugin there are two fields, one for the Application ID and one for the Client ID that made it look like that's really what I need. Unfortunately the error is still present and I really don't know what I could do with it. Here is the well known message:
Error: redirect_uri_mismatch
Request Details
cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/appstate
https://www.googleapis.com/auth/games
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.moments.write
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/plus.profile.agerange.read
https://www.googleapis.com/auth/plus.profile.language.read
https://www.googleapis.com/auth/plus.circles.members.read
response_type=code
access_type=offline
redirect_uri= < my bundle identifier without '_' characters >:/oauth2callback
state=16885367
gpsdk=1.5.0
verifier=12647966
display=page
client_id=123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
hl=en
The debug log contains only this:
2014-03-16 14:21:19.507 <my app>[1699:60b] GPGSAuthenticateWithCallback.
2014-03-16 14:21:19.509 <my app>[1699:60b] GPGSManager initializing and authenticating.
2014-03-16 14:21:19.512 <my app>[1699:60b] GPPSignIn initialized.
2014-03-16 14:21:19.514 <my app>[1699:60b] GPPSignIn attempting sign in now.
-> applicationWillResignActive()
-> applicationDidEnterBackground()
Does anyone know how could I solve this problem?
Thanks in advance!
Edit:
Maybe it wasn't obvious, but I have 2 bundle identifiers, both of them are linked to the same game service in Google Play Developer Console. The com.x.a_b_c belongs to the Android app, the com.x.abc belongs to the iOS app.
I was having redirect_uri_mismatch error while using UnityGPGPlugin. I was using "123456789123" as my Application ID instead of "123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".
However, I manage to get through the Google Sign In page after changing all my setup to "123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" as my Application ID. Including the GPGApplicationID in Info.plist.
Sad to say that I am having another problem now, but at least that's how I manage to get through that error. :)

Resources