ios 为什么推送通知在 testflight 上不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24044298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why push notifications is not working on testflight?
提问by Iman
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?
我已经将推送通知作为开发人员帐户进行了测试并且它有效,但是当我尝试将其放在 TestFlight 上以供测试人员测试时,它没有显示推送通知但数据已正确接收,所以有没有一种我需要为 TestFlight 生成证书吗?
回答by Eran
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.
但是当我尝试将它放在 TestFlight 上供测试人员测试时,它没有显示推送通知,但正确接收了数据。
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.
无论如何,如果我没记错的话,对于 TestFlight,您使用的是 AdHoc 配置文件,它适用于生产推送环境。因此,您需要生产推送证书才能推送到通过 TestFlight 安装应用程序的设备。此外,不要忘记开发设备令牌与生产设备令牌不同,因此请确保使用正确的令牌。
回答by Sandeep
- You need to use production certificate for testflight build.
- Also need to remove sanbox (sandbox mode) from push notification url in push sending script.
- 您需要使用生产证书进行 testflight 构建。
- 还需要从推送发送脚本中的推送通知 url 中删除沙箱(沙箱模式)。
回答by delarcomarta
If you use Firebase, you have to add in:
如果您使用 Firebase,则必须添加:
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]; }
试飞:
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox]; }
生产:
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; }
回答by Md Rais
For TestFlight, use
对于 TestFlight,请使用
- Production certificate
- "gateway.push.apple.com" at the server(back end job)
- 生产证书
- 服务器上的“gateway.push.apple.com”(后端工作)
回答by Ahmed Abdallah
if you used GCM. In Development:-
如果您使用 GCM。开发中:-
_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
In Distribution:-
在分销中:-
_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};
回答by Sailokesh Aithagoni
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 .
我们需要两个证书来发送通知,一个用于开发,一个用于生产。就我而言,我使用 PushSharp 解决方案发送通知。
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);
回答by Luat Vu Dinh
For someone uses Python apns(https://github.com/djacobs/PyAPNs):
对于有人使用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")
.
当您创建 APNS 对象时,例如apns = APNs(cert_file="cert.pem", key_file="key.pem")
. 您需要再添加一个参数use_sandbox
。它会apns = APNs(use_sandbox=False, cert_file="cert.pem", key_file="key.pem")
。
Happy coding.
快乐编码。
回答by AnupamChugh
Please ensure that you have set FirebaseAppDelegateProxyEnabled
to YES
in info.plist file.
请确保您已在 info.plist 文件中设置FirebaseAppDelegateProxyEnabled
为YES
。