[英]Xcode: push notifications to build on device work but not to TestFlight/App Store install on same device
I've realized that I can test push notifications in development and prod builds on local devices- but they don't work with real installs from TestFlight/App Store. 我已经意识到我可以在本地设备上的开发和产品构建中测试推送通知,但是它们不能与TestFlight / App Store中的实际安装一起使用。
I think this has to do with Xcode's signing of builds vs. archives, but I cannot figure out what to do to fix my current configuration. 我认为这与Xcode的版本与存档签名有关,但是我无法弄清楚该如何解决当前配置。 I use the Xcode auto signing, FYI.
我使用Xcode自动签名,仅供参考。
I use Mixpanel for event tracking and notifications, which also lets me confirm the device token is being retrieved successfully. 我使用Mixpanel进行事件跟踪和通知,这也使我可以确认已成功检索设备令牌。 I have my production push certificate uploaded there.
我的生产推送证书已上传到此处。
If I have a build running on my device, I can grab the token from a log message and send a push to it (using my prod push certificate) with a different utility called Pusher- this works perfectly. 如果我的设备上正在运行构建,则可以从日志消息中获取令牌,然后使用另一个名为Pusher的实用程序(使用我的产品推送证书)将推送发送给它-效果很好。
However, if I download my app from TestFlight or the App Store, start it, get the resulting token from Mixpanel, and send another notification via Mixpanel, it never shows up. 但是,如果我从TestFlight或App Store下载我的应用程序,启动它,从Mixpanel获取结果令牌,然后通过Mixpanel发送另一个通知,它将永远不会显示。 Going back to Pusher, if I attempt a push with the token from Mixpanel, I get an
APN invalid token
error. 回到Pusher,如果尝试使用Mixpanel的令牌进行推送,则会收到
APN invalid token
错误。
Both of these tokens were grabbed the same way- immediately after the user agrees to notifications or the push plugin finishes setup. 在用户同意通知或推送插件完成设置后,立即以相同的方式获取了这两个令牌。 They were also grabbed on the same code- but one from a running Xcode build, the other from an archive on the TestFlight.
它们也被相同的代码捕获-一个是从运行的Xcode构建中获取的,另一个是从TestFlight上的存档中获取的。
Project setup- I have the Push switch set to on in the Xcode Capabilities menu, and I've generated push certs for dev and production (well, 2 for prod by accident. I figured it was fine): 项目设置-我在Xcode Capabilities菜单中将Push开关设置为on,并且我已经为开发和生产生成了推送证书(嗯,偶然生成了2个推送证书。我认为这很好):
I also have the Distribution and Dev provisioning profiles created. 我还创建了分发和开发配置文件。 This is where my question lies- I read that Xcode doesn't use the Distribution profile you create until archiving, and uses it's own until then if you have Automatic Signing selected in the code signing settings.
这就是我的问题所在-我读到Xcode在归档之前不使用您创建的分发配置文件,而在此之前,如果您在代码签名设置中选择了“自动签名”,则使用它自己的。
Is that why I have 2 profiles here? 这就是为什么我在这里有2个个人资料吗? The one I created shows as Active & also lists Push Notifications under services if I expand the entry below:
如果我展开以下条目,我创建的将显示为“活动”,并且还会在服务下列出“推送通知”:
The cert my production provisioning profile is signed with is an iOS Distribution certificate that matches the team I have selected for signing: 与我的生产配置文件进行签名的证书是与我选择签名的团队匹配的iOS分发证书:
While writing this up I realized that maybe my release build settings, specifically signing, were wrong. 在撰写本文时,我意识到也许我的发行版本设置(特别是签名)是错误的。 I though they should also be using my
Iphone Distribution: MyCompany Inc (USA)
certificate (instead of the default iOS Developer
identity), since my Distribution provisioning profile is signed with that same certificate. 尽管我也应该使用我的
Iphone Distribution: MyCompany Inc (USA)
证书(而不是默认的iOS Developer
身份),因为我的Distribution Provisioning配置文件已使用同一证书签名。 Unfortunately this doesn't seem to work either. 不幸的是,这似乎也不起作用。
If my build settings look like this (or if I select the generic iOS Distribution
from the dropdown for Release identity): 如果我的构建设置如下所示(或者如果我从“发行版”标识的下拉列表中选择通用的
iOS Distribution
版):
I can't actually build- I get an error that there are conflicting provisioning settings. 我实际上无法构建-我收到一条错误消息,指出配置设置存在冲突。 If I use the
iPhone Distribution: MyCompany Inc (USA)
certificate just in the Release
line (not the Any iOS SDK
line), I can create an archive, but I see the same behavior. 如果仅在
Release
行(而不是Any iOS SDK
行)中使用iPhone Distribution: MyCompany Inc (USA)
证书,则可以创建一个存档,但是会看到相同的行为。
I thought for sure this was it, since I've been using my MyCompany Inc (USA) development team for provisioning when validating/uploading archives. 我一直以为是确定的,因为我一直在使用MyCompany Inc(USA)开发团队在验证/上传档案时进行配置。
I also tried turning off automatic signing and setting the debug and release profiles to the dev and prod provisioning profiles I made in the Apple Developer site. 我还尝试关闭自动签名,并将调试和发布配置文件设置为我在Apple Developer站点中创建的dev和prod供应配置文件。 No luck there either.
那里也没有运气。
Just to come full circle- this is the archive summary information I see when using automatic signing: 简而言之,这是使用自动签名时看到的存档摘要信息:
This is correct, right? 没错吧? The identity listed was used to sign the selected provisioning profile, so that should be all I need as far as proper signing, right?
列出的身份用于对所选的配置文件进行签名,因此就适当的签名而言,这应该是我所需要的,对吗? Given the other setup, of course.
当然,考虑其他设置。
I'm completely stumped at this point- how am I supposed to configure signing for archives? 在这一点上,我完全感到困惑-我应该如何配置档案签名?
This didn't end up being a signing issue after all- while I'm still a little bewildered on exactly what I need to do for signing release builds, it seems the Xcode automatic process handles it properly, given that the correct provisioning profile has been created in your Apple Developer account. 毕竟,这最终并没有成为一个签名问题,尽管我仍然对为发布版本进行签名所需要做的事情有些困惑,但考虑到正确的配置文件已经使Xcode自动流程能够正确处理已在您的Apple Developer帐户中创建。
There were 2 issues here: 这里有2个问题:
"priority": 10
to the custom data of a Mixpanel test notification, I am able to successfully send/receive them. "priority": 10
,我能够成功发送/接收它们。 I figured this out by playing with the dropdown in the screenshot of Pusher below: My own device would receive pushes with any of these 3 levels selected, but other devices would only receive pushes with the "Immediately" level or "Priority: None" level selected. 我自己的设备会收到选择了这3个级别中的任何一个的推送,但是其他设备只会收到选择了“立即”级别或“优先级:无”级别的推送。 Why?
为什么? I have no idea.
我不知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.