为什么推送通知不适用于testflight?

Ima*_*man 71 push-notification apple-push-notifications ios testflight

我已将测试推送通知作为开发人员帐户进行测试,但是当我尝试将其放在TestFlight上供测试人员测试时,它没有显示推送通知但是数据被正确接收,所以有一种我需要为TestFlight生成的证书?

Era*_*ran 80

但是当我试图将它放在TestFlight上供测试人员测试时,它没有显示推送通知但是数据被正确接收.

那句话令人困惑.如果您没有收到推送通知,那么正确接收了哪些数据?

无论如何,如果我没记错的话,对于TestFlight,您使用的是AdHoc配置文件,该配置文件适用于生产推送环境.因此,您需要一个生产推送证书才能推送到通过TestFlight安装应用程序的设备.另外,不要忘记开发设备令牌与生产设备令牌不同,因此请确保使用正确的令牌.

  • @PeterPiper`如果令牌来自沙盒环境,例如当您在内部测试开发版本时,则无法将其发送到生产推送服务.每个推送环境都会为同一设备或计算机发出不同的令牌.如果您确实将设备令牌发送到错误的环境,则推送服务会将其视为无效令牌并丢弃通知.取自[here](https://developer.apple.com/library/ios/technotes/ tn2265/_index.html). (6认同)
  • 我还没有在文档中看到有关生产设备令牌的任何内容 - 您能指定一下吗? (2认同)

San*_*eep 40

1.您需要使用生产证书进行testflight构建.2.还需要从推送发送脚本中的推送通知URL中删除sanbox(沙盒模式).

  • 测试:gateway.sandbox.push.apple.com制作:gateway.push.apple.com (5认同)

小智 12

如果您使用Firebase,则必须添加:

  • TestFlight:

    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox]; 
    }
    
    Run Code Online (Sandbox Code Playgroud)
  • 生产:

    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; 
    }
    
    Run Code Online (Sandbox Code Playgroud)

  • @GáborAngyal - 不清楚会发生什么.有趣的是,这句话"如果令牌类型设置为FIRInstanceIDAPNSTokenTypeUnknown实例id会读取配置轮廓找出令牌类型." 从[火力地堡API FIRInstanceID setAPNSToken:类型:](https://firebase.google.com/docs/reference/ios/firebaseinstanceid/api/reference/Classes/FIRInstanceID#/c:objc(CS)FIRInstanceID(IM)setAPNSToken:类型:).从逻辑上讲,**每个**都可以简单地执行`type:FIRInstanceIDAPNSTokenTypeUnknown`,这样我们就不必记得改变它.我自己没试过...... (2认同)
  • 使用Firebase 4.0新的Swift语法,现在为Messaging.messaging()。setAPNSToken(deviceToken,type:.unknown) (2认同)

Md *_*ais 6

对于TestFlight,请使用

  1. 生产证明书
  2. 服务器上的“ gateway.push.apple.com”(后端作业)


Ahm*_*lah 5

如果您使用GCM 开发中:-

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
Run Code Online (Sandbox Code Playgroud)

在分销: -

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};
Run Code Online (Sandbox Code Playgroud)