ios iPhone:生产证书推送通知测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6413188/
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
iPhone: Push Notification Testing on Production Certificate
提问by applefreak
I have a quick question. I have been testing Development Push Notification Certificate for my iPhone App and its been working fine. I just want to know that is it possible to test Production Certificate before submitting my application to AppStore? I did try but message is not coming along when I use production certificate. Does Apple required application to be in AppStore when I use production certificate?
我有一个快速的问题。我一直在为我的 iPhone 应用程序测试开发推送通知证书并且它运行良好。我只想知道在将我的应用程序提交到 AppStore 之前是否可以测试生产证书?我确实尝试过,但是当我使用生产证书时没有出现消息。当我使用生产证书时,Apple 是否要求应用程序在 AppStore 中?
Thanks.
谢谢。
回答by Roger
If you create an Ad-Hoc Profile, you'll find that it uses the production certificate, that's possibly the easiest way of testing it out.
如果您创建 Ad-Hoc 配置文件,您会发现它使用生产证书,这可能是测试它的最简单方法。
UPDATE:
更新:
See the Apple documentation here
请参阅此处的 Apple 文档
There are a number of steps to this but in essence;
这有许多步骤,但本质上是这样;
1) The team leader needs to create a new DISTRIBUTION provisioning profile. This is done by selecting "Ad Hoc" rather than "App Store" when creating a new profile. Note by the way that you can't use a wildcard app id for this, you need to have a specific app id for the application although you may well have this already.
1) 团队负责人需要创建一个新的 DISTRIBUTION 配置文件。这是通过在创建新配置文件时选择“Ad Hoc”而不是“App Store”来完成的。请注意,您不能为此使用通配符应用程序 id,您需要为应用程序指定一个特定的应用程序 id,尽管您可能已经有了它。
2) Setup your system so that build for archive uses a newly created Ad Hoc configuration, the steps required for setting this up are well documented online, here is one example.
2) 设置您的系统,以便存档构建使用新创建的 Ad Hoc 配置,设置所需的步骤在网上有详细记录,这里是一个示例。
3) Now when you distribute the .ipa to devices linked to your Ad Hoc provisioning profile, you will find that the push notification system is using the production servers.
3) 现在,当您将 .ipa 分发到链接到您的 Ad Hoc 配置文件的设备时,您会发现推送通知系统正在使用生产服务器。
As an aside, I find that testflightapp is really useful for managing the distribution of Ad Hoc builds and although I've only discovered it recently, it's saving me hours at the moment as I'm in the middle of running a beta test programme.
顺便说一句,我发现 testflightapp 对于管理 Ad Hoc 构建的分发非常有用,虽然我最近才发现它,但它现在为我节省了几个小时,因为我正在运行 beta 测试程序。
回答by Christine
For Adhoc distribution, Please follow the instructions below:
对于临时分发,请按照以下说明进行操作:
- In Provisioning Portal, Create a Distribution certificate.
- Get the "Device ID" of the iPhone that you intend to use for testing. Open iTunes -> Connect your device -> Select your device -> In Summary Pane, Click on Serial Number label, it will change to identifier (40 Hex characters) -> Choose Edit, Copy.
- In Provisioning portal, Go to Devices -> Add new Device -> Enter the copied Device ID and give it a name.
- In Provisioning portal, Create a Distribution Provisioning Profile. (Go to Provisioning -> Distribution). For Distibution type , Check "AdHoc". Select the App Id, If you have a distribution certificate, it will automatically be selected here. Select the newly entered device and Submit. Download this Provisioning Profile.
- In Xcode, Window -> Organiser. Click on Devices and select Library -> Provisioning Profiles. If you are the admin, then Clicking on Refresh should fetch the newly created provisioning profile. If not, Drag and Drop the Adhoc Provisioning Profile to this list.
- In Xcode, in your project Build Settings -> Code Signing Identity -> Release section, Select "iPhone Distribution". For "Any iOS SDK", Select the newly created Provisioning Profile. It will be available in the list.
- In Xcode, Product -> Archive. Once it finishes, Archiving, it will open the Archive window automatically. Select the project and click Distribute, In the Distribute window, Select "Save for Enterprise or AdHoc Deployment" -> Select the "Code Signing Identity" which corresponds to the new Provisioning Profile. Continue the process and this will create an ".ipa" file.
- Send this .ipa file and the new provisioning profile for testing adHoc distribution.
- 在 Provisioning Portal 中,创建分发证书。
- 获取您打算用于测试的 iPhone 的“设备 ID”。打开 iTunes -> 连接您的设备 -> 选择您的设备 -> 在摘要窗格中,单击序列号标签,它将更改为标识符(40 个十六进制字符)-> 选择编辑、复制。
- 在配置门户中,转到设备 -> 添加新设备 -> 输入复制的设备 ID 并为其命名。
- 在供应门户中,创建分发供应配置文件。(转至配置 -> 分发)。对于分发类型,选中“AdHoc”。选择App Id,如果你有分发证书,这里会自动选择。选择新输入的设备并提交。下载此配置文件。
- 在 Xcode 中,窗口 -> 管理器。单击设备并选择库 -> 配置文件。如果您是管理员,则单击“刷新”应获取新创建的配置文件。如果没有,请将临时供应配置文件拖放到此列表中。
- 在 Xcode 中,在您的项目 Build Settings -> Code Signing Identity -> Release 部分,选择“iPhone Distribution”。对于“Any iOS SDK”,选择新创建的 Provisioning Profile。它将在列表中可用。
- 在 Xcode 中,产品 -> 存档。完成存档后,它将自动打开存档窗口。选择项目并单击分发,在分发窗口中,选择“Save for Enterprise or AdHoc Deployment”-> 选择与新 Provisioning Profile 对应的“Code Signing Identity”。继续这个过程,这将创建一个“.ipa”文件。
- 发送此 .ipa 文件和新的配置文件以测试 adHoc 分发。
How to load the adHoc distribution on the test device:
如何在测试设备上加载 adHoc 发行版:
- Open iTunes, Connect your test device.
- Drag and Drop the new provisioning profile to iTunes.
- Drag and Drop the .ipa file iTunes.
- Sync ur device. This would load the app.
- 打开 iTunes,连接您的测试设备。
- 将新的配置文件拖放到 iTunes。
- 拖放 .ipa 文件 iTunes。
- 同步您的设备。这将加载应用程序。
For Push Notifications to work on Adhoc distribution:
对于在 Adhoc 分发上工作的推送通知:
- Use the production certificates.
- Use production APN Host: gateway.push.apple.com
- Use production APN Feedback Host: feedback.push.apple.com.
- 使用生产证书。
- 使用生产 APN 主机:gateway.push.apple.com
- 使用生产 APN 反馈主机:feedback.push.apple.com。
There are severeral checklist that one should keep in mind while testing pushnotification for development environment. Most of them are already mentioned above. But this is one thing THAT SOLVED MY PROBLEM and i would like to share. I hope it helps someone. And that is:
在测试开发环境的推送通知时,应该牢记一些严格的清单。其中大部分已经在上面提到过。但这是解决了我的问题的一件事,我想分享。我希望它可以帮助某人。那就是:
Please be aware of the device token-ID, which is different for the development && Production environment .
请注意设备令牌 ID,它在开发 && 生产环境中是不同的。
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *deviceTokenStr = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:deviceTokenStr message:Nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
回答by Bigood
Alternative
选择
If you will to save even more time, and debug1test these notifications in a production environment, without having to build & distribute each time, follow these steps :
如果您想节省更多时间,并在生产环境中调试1测试这些通知,而不必每次都构建和分发,请按照以下步骤操作:
- Create & install your Distribution provisioning profile,
- Create a new scheme using the Release configuration instead of Debug (see the 2nd part of the post for instructions) and select it,
- Make sure you have your distribution profile selected for the release configuration under your app's target build settings,
- Rock'n'roll!
- 创建并安装您的分发配置文件,
- 使用 Release 配置而不是 Debug 创建一个新方案(有关说明,请参阅帖子的第二部分)并选择它,
- 确保在应用程序的目标构建设置下为发布配置选择了分发配置文件,
- 摇滚乐!
How to create a new scheme
如何创建新方案
Click on your app's name, on the left corner :
Select "New scheme..." and give it a name,
- Then, edit it by opening this menu again and select "Edit scheme...",
Select "Release" under "Build configuration" :
Select it, so it appear on the upper left corner, and you're done!
单击左上角的应用名称:
选择“新方案...”并为其命名,
- 然后,通过再次打开此菜单并选择“编辑方案...”进行编辑,
在“构建配置”下选择“发布”:
选择它,让它出现在左上角,你就完成了!
1 : you can't use the distribution nor the ad-hoc provisioning to debug, see this thread
1 :您不能使用分发或临时配置进行调试,请参阅此线程