# 使用 CocoaPods 设置 InboxUI

<Aside type="caution" title="旧版模块">
保留 Pushwoosh InboxUI 是为了向后兼容。对于新项目，请使用 [Pushwoosh InboxKit](/zh/developer/pushwoosh-sdk/ios-sdk/setting-up-pushwoosh-inboxkit-ios/) — 现代的 UIKit 替代品。
</Aside>

1. 在您的项目目录中，从终端运行 '**pod init**' 命令。

2. 打开新创建的 Podfile。

3. 在您的项目名称目标下添加 Pushwoosh 依赖项：

```ruby
# Uncomment the next line to define a global platform for your project 
# platform: ios, ‘9.0’

target ‘MyApp’ do 
   # Comment the next line if you don’t want to use dynamic frameworks 
   use_frameworks!

   # Pods for MyApp
   pod 'PushwooshInboxUI'

end
```

<Aside type="note">
如果您想使用 _PushwooshInboxUI.xcframework_，请在您的 Podfile 中使用 **pod 'PushwooshInboxUIXCFramework'**。



**Catalyst 集成**

Catalyst 使用 .xcframework，因此您应该使用 **PushwooshXCFramework** pod 而不是 **Pushwoosh**：

```
pod 'PushwooshXCFramework'
```
</Aside>

4. 在您的项目目录中，在终端中运行以下命令：

```
pod install
```

5. 打开新创建的 \<_your_project_name_\>**\.xcworkspace** 文件。

6. 做得好！您已成功将 Pushwoosh InboxUI 集成到您的项目中。

## 添加 Pushwoosh InboxUI 代码

要在您的应用中显示 Inbox UI，请添加 Inbox 视图控制器：

<Tabs syncKey="code-example">
<TabItem label="Swift">
```swift
self.navigationController?.pushViewController(PWIInboxUI.createInboxController(with: PWIInboxStyle.default()), animated: true)
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
[self.navigationController pushViewController:[PWIInboxUI createInboxControllerWithStyle:[PWIInboxStyle  defaultStyle]] animated:YES];
```
</TabItem>
</Tabs>

要使 Inbox 与您的应用外观匹配，请更改 `PWIInboxStyle` 的参数。您可以自定义字体、背景颜色等参数。

<Tabs syncKey="code-example">
<TabItem label="Swift">
```swift
//creating a new Inbox style
let inboxStyle = PWIInboxStyle.customStyle(withDefaultImageIcon: UIImage.init(named: "custom_image"),
textColor: UIColor.darkText,
accentColor: UIColor.blue,
font: UIFont.systemFont(ofSize: 17))

inboxStyle?.backgroundColor = UIColor.init(white: 1, alpha: 1)
inboxStyle?.listErrorMessage = NSLocalizedString("Custom error message", comment: "Custom error message")
inboxStyle?.listEmptyMessage = NSLocalizedString("Custom empty message", comment: "Custom empty message")

PWIInboxStyle.setupDefaultStyle(inboxStyle)
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
//creating a new Inbox style
PWIInboxStyle *inboxStyle = [PWIInboxStyle  customStyleWithDefaultImageIcon:[UIImage imageNamed:@"custom_image"]
textColor:UIColor.darkTextColor
accentColor:UIColor.blueColor
font:[UIFont systemFontOfSize:17]];

inboxStyle.backgroundColor = [UIColor colorWithWhite:1 alpha:1];
inboxStyle.listErrorMessage = NSLocalizedString(@"Custom error message", @"Custom error message");
inboxStyle.listEmptyMessage = NSLocalizedString(@"Custom empty message", @"Custom empty message");

[PWIInboxStyle setupDefaultStyle:inboxStyle];
```
</TabItem>
</Tabs>

## 自定义

要自定义 Inbox UI 样式，请参考：

<LinkCard
  title="PWIInboxStyle.h"
  href="https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/iOS_SDK/PushwooshInboxUI/PushwooshInboxUI/Public/PWIInboxStyle.h"
/>

<LinkCard
  title="PWIInboxUI.h"
  href="https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/iOS_SDK/PushwooshInboxUI/PushwooshInboxUI/Public/PWIInboxUI.h"
/>


有关更多详细信息，请参阅 [Inbox 示例](https://github.com/Pushwoosh/pushwoosh-quickstart-ios/tree/main/inbox)。