Why push notifications is not working on testflight?
Solution 1
But when i tried to put it on TestFlight for the testers to test it, it didn't show a push notification but the data is correctly received.
That sentence is confusing. If you didn't get the push notification, what data is correctly received?
Anyway, if I recall correctly, for TestFlight you are using an AdHoc provisioning profile, which works with the production push environment. Therefore you'll need a production push certificate in order to push to devices that installed the app via TestFlight. In addition, don't forget that development device tokens are different than production device tokens, so make sure you are using the correct tokens.
Solution 2
- You need to use production certificate for testflight build.
- Also need to remove sanbox (sandbox mode) from push notification url in push sending script.
Solution 3
If you use Firebase, you have to add in:
TestFlight:
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox]; }
Production:
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; }
Solution 4
For TestFlight, use
- Production certificate
- "gateway.push.apple.com" at the server(back end job)
Solution 5
if you used GCM. In Development:-
_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
In Distribution:-
_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};
Related videos on Youtube
Iman
Updated on July 30, 2020Comments
-
Iman almost 4 years
I have tested push notifications as a developer account and it worked, But when i tried to put it on TestFlight for the testers to test it, it didn't show a push notification but the data is correctly received, So is there a kind of certificate that i need to generate for TestFlight?
-
Tarun Seera about 8 yearsUse production certificate for TestFlight, because its a distribution build, and use ssl://gateway.push.apple.com:2195 instead of sandbox URL to send the notification
-
-
Bergrebell over 8 yearsi haven't seen anything about production device tokens in the docs - could you specify this a bit?
-
Eran over 8 years@PeterPiper
If the token came from the sandbox environment, such as when you are testing a development build in house, you can't send it to the production push service. Each push environment will issue a different token for the same device or computer. If you do send a device token to the wrong environment, the push service will see that as an invalid token and discard the notification.
taken from here. -
B.Y about 8 years#1 was what I was supposed to remember. Thanks.
-
mc. about 8 yearsTesting:gateway.sandbox.push.apple.com Production:gateway.push.apple.com
-
Gábor Angyal over 7 yearsThis might be a very stupid question, but what happens if you do both?
-
user3751548 over 7 yearsDear @Eran, do you have any tutorial to show how to create production certificate ?
-
ToolmakerSteve over 7 years@GáborAngyal - Not clear what happens. Interesting is this sentence "If the token type is set to FIRInstanceIDAPNSTokenTypeUnknown InstanceID will read the provisioning profile to find out the token type." from Firebase API FIRInstanceID setAPNSToken:type:. Logically, that says everyone could simply do
type: FIRInstanceIDAPNSTokenTypeUnknown
, so that we don't have to remember to change this. Haven't tried this myself... -
Tope about 7 yearsI tried using the
FIRInstanceIDAPNSTokenTypeUnknown
valuef or the type argument and can confirm that I was able to receive push notification on testflight builds -
Apostolos almost 7 yearsWould that apply also for Notifications for the GameKit?
-
Eran almost 7 years@tallis I don't know.
-
dmathewwws over 6 yearswith Firebase 4.0 new Swift syntax it is now Messaging.messaging().setAPNSToken(deviceToken, type: .unknown)
-
alexandre9865 about 3 yearswhat is the file I need to add this function from answer?
-
alexandre9865 about 3 yearsWhere can I change this config of server?
-
Md Rais about 3 yearsHi Alexandre, I am not sure exactly where the backend developer declares the gateway coz Im not a backend developer. But I know that at some point we have to write it.
-
fullStackChris about 3 yearsOk... but then how can we control sending test notification only to our test clients if they use the same certificates?
-
fullStackChris about 3 years@alexandre9865 - this is AppDelegate.m