Why push notifications is not working on testflight?

60,031

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

  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

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

  1. Production certificate
  2. "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};
Share:
60,031

Related videos on Youtube

Iman
Author by

Iman

Updated on July 30, 2020

Comments

  • Iman
    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
      Tarun Seera about 8 years
      Use 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
    Bergrebell over 8 years
    i haven't seen anything about production device tokens in the docs - could you specify this a bit?
  • Eran
    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
    B.Y about 8 years
    #1 was what I was supposed to remember. Thanks.
  • mc.
    mc. about 8 years
    Testing:gateway.sandbox.push.apple.com Production:gateway.push.apple.com
  • Gábor Angyal
    Gábor Angyal over 7 years
    This might be a very stupid question, but what happens if you do both?
  • user3751548
    user3751548 over 7 years
    Dear @Eran, do you have any tutorial to show how to create production certificate ?
  • ToolmakerSteve
    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
    Tope about 7 years
    I tried using the FIRInstanceIDAPNSTokenTypeUnknown valuef or the type argument and can confirm that I was able to receive push notification on testflight builds
  • Apostolos
    Apostolos almost 7 years
    Would that apply also for Notifications for the GameKit?
  • Eran
    Eran almost 7 years
    @tallis I don't know.
  • dmathewwws
    dmathewwws over 6 years
    with Firebase 4.0 new Swift syntax it is now Messaging.messaging().setAPNSToken(deviceToken, type: .unknown)
  • alexandre9865
    alexandre9865 about 3 years
    what is the file I need to add this function from answer?
  • alexandre9865
    alexandre9865 about 3 years
    Where can I change this config of server?
  • Md Rais
    Md Rais about 3 years
    Hi 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
    fullStackChris about 3 years
    Ok... but then how can we control sending test notification only to our test clients if they use the same certificates?
  • fullStackChris
    fullStackChris about 3 years
    @alexandre9865 - this is AppDelegate.m