iPhone:在生产证书上推送通知测试

时间:2022-08-26 22:14:20

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之前是否有可能测试生产证书?我试过了,但是当我使用生产证书的时候没有消息。当我使用产品证书时,苹果是否要求应用在AppStore ?

Thanks.

谢谢。

3 个解决方案

#1


36  

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.

如果您创建一个特别的概要文件,您会发现它使用了生产证书,这可能是测试它的最简单的方法。

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)团队负责人需要创建一个新的分发准备配置文件。这是通过在创建新概要时选择“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)设置您的系统,以便存档使用新创建的临时配置,设置此设置所需的步骤在网上有详细记录,这里有一个示例。

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分发到连接到您的临时配置文件的设备时,您将发现推送通知系统正在使用生产服务器。

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对于管理临时构建的发布非常有用,尽管我最近才发现它,但它为我节省了很多时间,因为我正在运行beta测试程序。

#2


7  

For Adhoc distribution, Please follow the instructions below:

如需特别派发,请按下列指示:

  1. In Provisioning Portal, Create a Distribution certificate.
  2. 在供应门户中,创建分发证书。
  3. 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.
  4. 获取打算用于测试的iPhone的“设备ID”。打开iTunes ->连接你的设备->在摘要面板中选择你的设备->,点击序列号标签,它将会更改为标识符(40hex字符)->选择编辑,复制。
  5. In Provisioning portal, Go to Devices -> Add new Device -> Enter the copied Device ID and give it a name.
  6. 在供应门户中,转到设备—>添加新设备—>输入复制的设备ID并为其命名。
  7. 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.
  8. 在供应门户中,创建一个分发供应配置文件。(转到供应->发行版)。对于蒸馏类型,检查“临时”。选择App Id,如果您有一个发行证书,它将自动在这里被选中。选择新输入的设备并提交。下载这个配置概要文件。
  9. 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.
  10. 在Xcode中,窗口->的组织者。单击设备并选择Library ->准备配置文件。如果您是admin,那么单击Refresh应该获取新创建的配置文件。如果没有,将临时配置文件拖放到此列表中。
  11. 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.
  12. 在Xcode中,在您的项目构建设置->代码签名身份->发布部分,选择“iPhone发行版”。对于“任何iOS SDK”,选择新创建的供应配置文件。它可以在列表中找到。
  13. 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.
  14. 在Xcode中,Product ->存档。一旦它完成,归档,它将自动打开存档窗口。选择项目并单击Distribute,在分发窗口中,选择“Save for Enterprise or AdHoc Deployment”——>选择与新的供应配置文件对应的“代码签名标识”。继续这个过程,这将创建一个”。异丙醇”文件。
  15. Send this .ipa file and the new provisioning profile for testing adHoc distribution.
  16. 发送此.ipa文件和用于测试临时发行版的新配置文件。

How to load the adHoc distribution on the test device:

如何在测试设备上加载adHoc分布:

  1. Open iTunes, Connect your test device.
  2. 打开iTunes,连接你的测试设备。
  3. Drag and Drop the new provisioning profile to iTunes.
  4. 拖放新的供应配置文件到iTunes。
  5. Drag and Drop the .ipa file iTunes.
  6. 拖放。ipa文件iTunes。
  7. Sync ur device. This would load the app.
  8. 同步你的设备。这将加载应用程序。

For Push Notifications to work on Adhoc distribution:

为推动通知工作特别分发:

  1. Use the production certificates.
  2. 使用生产证书。
  3. Use production APN Host: gateway.push.apple.com
  4. 使用生产APN主机:gateway.push.apple.com
  5. Use production APN Feedback Host: feedback.push.apple.com.
  6. 使用生产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:

在为开发环境测试pushnotification时,需要记住几个清单。上面已经提到了其中的大多数。但有一件事解决了我的问题,我想与大家分享。我希望它能帮助某人。这就是:

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];
}

#3


5  

Alternative

If you will to save even more time, and debug 1 test these notifications in a production environment, without having to build & distribute each time, follow these steps :

如果您想节省更多时间,并在生产环境中测试这些通知,而不必每次都构建和分发,请遵循以下步骤:

  1. Create & install your Distribution provisioning profile,
  2. 创建和安装您的分发配置文件,
  3. Create a new scheme using the Release configuration instead of Debug (see the 2nd part of the post for instructions) and select it,
  4. 使用发布配置而不是调试创建一个新的方案(参见文章第二部分的说明)并选择它,
  5. Make sure you have your distribution profile selected for the release configuration under your app's target build settings,
  6. 确保在应用的目标构建设置下为发布配置选择了您的发行配置文件,
  7. Rock'n'roll!
  8. 摇滚乐!

How to create a new scheme

  1. Click on your app's name, on the left corner :

    点击app名称,在左下角:

    iPhone:在生产证书上推送通知测试

  2. Select "New scheme..." and give it a name,

    选择“新方案…”并给它一个名字,

  3. Then, edit it by opening this menu again and select "Edit scheme...",
  4. 然后,重新打开这个菜单并选择“编辑方案…”
  5. Select "Release" under "Build configuration" :

    在“构建配置”下选择“发布”:

    iPhone:在生产证书上推送通知测试

  6. 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:您不能使用发行版或临时配置来调试,请参见这个线程

#1


36  

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.

如果您创建一个特别的概要文件,您会发现它使用了生产证书,这可能是测试它的最简单的方法。

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)团队负责人需要创建一个新的分发准备配置文件。这是通过在创建新概要时选择“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)设置您的系统,以便存档使用新创建的临时配置,设置此设置所需的步骤在网上有详细记录,这里有一个示例。

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分发到连接到您的临时配置文件的设备时,您将发现推送通知系统正在使用生产服务器。

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对于管理临时构建的发布非常有用,尽管我最近才发现它,但它为我节省了很多时间,因为我正在运行beta测试程序。

#2


7  

For Adhoc distribution, Please follow the instructions below:

如需特别派发,请按下列指示:

  1. In Provisioning Portal, Create a Distribution certificate.
  2. 在供应门户中,创建分发证书。
  3. 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.
  4. 获取打算用于测试的iPhone的“设备ID”。打开iTunes ->连接你的设备->在摘要面板中选择你的设备->,点击序列号标签,它将会更改为标识符(40hex字符)->选择编辑,复制。
  5. In Provisioning portal, Go to Devices -> Add new Device -> Enter the copied Device ID and give it a name.
  6. 在供应门户中,转到设备—>添加新设备—>输入复制的设备ID并为其命名。
  7. 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.
  8. 在供应门户中,创建一个分发供应配置文件。(转到供应->发行版)。对于蒸馏类型,检查“临时”。选择App Id,如果您有一个发行证书,它将自动在这里被选中。选择新输入的设备并提交。下载这个配置概要文件。
  9. 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.
  10. 在Xcode中,窗口->的组织者。单击设备并选择Library ->准备配置文件。如果您是admin,那么单击Refresh应该获取新创建的配置文件。如果没有,将临时配置文件拖放到此列表中。
  11. 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.
  12. 在Xcode中,在您的项目构建设置->代码签名身份->发布部分,选择“iPhone发行版”。对于“任何iOS SDK”,选择新创建的供应配置文件。它可以在列表中找到。
  13. 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.
  14. 在Xcode中,Product ->存档。一旦它完成,归档,它将自动打开存档窗口。选择项目并单击Distribute,在分发窗口中,选择“Save for Enterprise or AdHoc Deployment”——>选择与新的供应配置文件对应的“代码签名标识”。继续这个过程,这将创建一个”。异丙醇”文件。
  15. Send this .ipa file and the new provisioning profile for testing adHoc distribution.
  16. 发送此.ipa文件和用于测试临时发行版的新配置文件。

How to load the adHoc distribution on the test device:

如何在测试设备上加载adHoc分布:

  1. Open iTunes, Connect your test device.
  2. 打开iTunes,连接你的测试设备。
  3. Drag and Drop the new provisioning profile to iTunes.
  4. 拖放新的供应配置文件到iTunes。
  5. Drag and Drop the .ipa file iTunes.
  6. 拖放。ipa文件iTunes。
  7. Sync ur device. This would load the app.
  8. 同步你的设备。这将加载应用程序。

For Push Notifications to work on Adhoc distribution:

为推动通知工作特别分发:

  1. Use the production certificates.
  2. 使用生产证书。
  3. Use production APN Host: gateway.push.apple.com
  4. 使用生产APN主机:gateway.push.apple.com
  5. Use production APN Feedback Host: feedback.push.apple.com.
  6. 使用生产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:

在为开发环境测试pushnotification时,需要记住几个清单。上面已经提到了其中的大多数。但有一件事解决了我的问题,我想与大家分享。我希望它能帮助某人。这就是:

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];
}

#3


5  

Alternative

If you will to save even more time, and debug 1 test these notifications in a production environment, without having to build & distribute each time, follow these steps :

如果您想节省更多时间,并在生产环境中测试这些通知,而不必每次都构建和分发,请遵循以下步骤:

  1. Create & install your Distribution provisioning profile,
  2. 创建和安装您的分发配置文件,
  3. Create a new scheme using the Release configuration instead of Debug (see the 2nd part of the post for instructions) and select it,
  4. 使用发布配置而不是调试创建一个新的方案(参见文章第二部分的说明)并选择它,
  5. Make sure you have your distribution profile selected for the release configuration under your app's target build settings,
  6. 确保在应用的目标构建设置下为发布配置选择了您的发行配置文件,
  7. Rock'n'roll!
  8. 摇滚乐!

How to create a new scheme

  1. Click on your app's name, on the left corner :

    点击app名称,在左下角:

    iPhone:在生产证书上推送通知测试

  2. Select "New scheme..." and give it a name,

    选择“新方案…”并给它一个名字,

  3. Then, edit it by opening this menu again and select "Edit scheme...",
  4. 然后,重新打开这个菜单并选择“编辑方案…”
  5. Select "Release" under "Build configuration" :

    在“构建配置”下选择“发布”:

    iPhone:在生产证书上推送通知测试

  6. 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:您不能使用发行版或临时配置来调试,请参见这个线程