Why push notifications is not working on testflight?

IosPush NotificationApple Push-NotificationsTestflight

Ios Problem Overview


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?

Ios Solutions


Solution 1 - Ios

>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 - Ios

  1. You need to use production certificate for testflight build.
  2. Also need to remove sanbox (sandbox mode) from push notification url in push sending script.

Solution 3 - Ios

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 - Ios

For TestFlight, use

  1. Production certificate
  2. "gateway.push.apple.com" at the server(back end job)

Solution 5 - Ios

if you used GCM. In Development:-

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};

In Distribution:-

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};

Solution 6 - Ios

We need two certificates for sending notifications, one for development and one for production. In my case I'm using PushSharp solution to send notification .

This is for development:

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, "development.p12", "password");
var broker = new ApnsServiceBroker(config);

This is for Production:

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, "production.p12", "password");
var broker = new ApnsServiceBroker(config);

Solution 7 - Ios

For someone uses Python apns (https://github.com/djacobs/PyAPNs):

When you create APNS object such apns = APNs(cert_file="cert.pem", key_file="key.pem"). You need to add one more parameter use_sandbox. It will be apns = APNs(use_sandbox=False, cert_file="cert.pem", key_file="key.pem").

Happy coding.

Solution 8 - Ios

Please ensure that you have set FirebaseAppDelegateProxyEnabled to YES in info.plist file.

Solution 9 - Ios

For Firebase try this:

#if DEBUG
    Messaging.messaging().setAPNSToken(apnsToken, type: .sandbox)
#else
    Messaging.messaging().setAPNSToken(apnsToken, type: .prod)
#endif

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionImanView Question on Stackoverflow
Solution 1 - IosEranView Answer on Stackoverflow
Solution 2 - IosSandeepView Answer on Stackoverflow
Solution 3 - IosdelarcomartaView Answer on Stackoverflow
Solution 4 - IosMd RaisView Answer on Stackoverflow
Solution 5 - IosAhmed AbdallahView Answer on Stackoverflow
Solution 6 - IosSailokesh AithagoniView Answer on Stackoverflow
Solution 7 - IosLuat Vu DinhView Answer on Stackoverflow
Solution 8 - IosAnupamChughView Answer on Stackoverflow
Solution 9 - IosAndrey M.View Answer on Stackoverflow