# Xamarin 消息收件箱

<Aside type="caution" title="重要提示">
  **此软件包已弃用。**

由于 Microsoft 已放弃 Xamarin，因此不再计划更新它。他们已终止对该框架的支持，并且它将不符合未来操作系统的版本。

> Xamarin 对所有 Xamarin SDK（包括 Xamarin.Forms）的支持已于 2024 年 5 月 1 日结束。Android API 34 和 Xcode 15 SDK（iOS 和 iPadOS 17、macOS 14）是 Xamarin 从现有 Xamarin SDK 定位的最终版本（即，不计划新的 API）。[了解更多](https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin)

iOS 18（计划于 2024 年 9 月发布）和 Android 15（预计于 2024 年 8 月发布）将不再受 Xamarin 支持。此插件也将不符合任何平台的新政策（如果有）。

我们建议考虑其他框架，例如 Microsoft 的 MAUI（与 Xamarin 类似）或其他框架。有关将 Xamarin 项目升级到 .NET 的更多信息，请参阅 [从 Xamarin 升级到 .NET 和 .NET MAUI 文档](https://learn.microsoft.com/en-us/dotnet/maui/migration/?view=net-maui-9.0&WT.mc_id=dotnet-35129-website)。
</Aside>

## Xamarin.iOS

1. 将 **Pushwoosh.Inbox.Xamarin.iOS** Nuget 软件包添加到您的项目。
2. 在您的项目中，打开 **AppDelegate.cs** 并通过添加 `using Pushwoosh.Inbox` 行来连接 **Pushwoosh.Inbox**。
3. 要在您的应用中显示 Inbox UI，请添加 **Inbox 视图控制器**：

```csharp
NavigationController.PushViewController(PWIInboxUI.CreateInboxControllerWithStyle(PWIInboxStyle.DefaultStyle()), true);
```

4. 为了使 Inbox 看起来像是您应用的一部分，请更改 **PWIInboxStyle** 的参数。您可以自定义字体、背景颜色等参数。

```csharp
PWIInboxStyle inboxStyle = PWIInboxStyle.CustomStyleWithDefaultImageIcon(
    UIImage.FromBundle("Default"),
    UIColor.DarkTextColor,
    UIColor.Blue,
    UIFont.SystemFontOfSize(17));
inboxStyle.BackgroundColor = UIColor.White;
inboxStyle.SelectionColor = UIColor.Orange;
inboxStyle.ListErrorMessage = "Custom error message";
inboxStyle.ListEmptyMessage = "Custom empty message";
PWIInboxStyle.SetupDefaultStyle(inboxStyle);
```

<Aside type="note">
有关更多详细信息，请查看 Inbox 示例 [https://github.com/Pushwoosh/pushwoosh-xamarin/tree/master/Samples/iOS](https://github.com/Pushwoosh/pushwoosh-xamarin/tree/master/Samples/iOS)
</Aside>

## Xamarin.Android

1. 将 **Pushwoosh.Inbox.Xamarin.Android** Nuget 软件包添加到您的项目。
2. 通过添加以下行来连接 **Pushwoosh.Inbox**：

```csharp
using Pushwoosh.Inbox;
using Pushwoosh.Inbox.UI;
using Pushwoosh.Inbox.UI.Activity;
```

3. 要在您的应用中显示 Inbox UI，请启动 **InboxActivity**：

```csharp
Intent intent = new Intent(this, typeof(InboxActivity));
StartActivity(intent);
```

4. 为了使 Inbox 看起来像是您应用的一部分，请更改 **PushwooshInboxStyle** 的参数。您可以自定义字体、背景颜色等参数。

```
PushwooshInboxStyle inboxStyle = PushwooshInboxStyle.Instance;
inboxStyle.BackgroundColor = new Integer(Color.GhostWhite);
inboxStyle.HighlightColor = new Integer(Color.ParseColor("#ff00ff"));
inboxStyle.ListErrorMessage = "Custom error message";
inboxStyle.ListEmptyText = "Custom empty message";
inboxStyle.DefaultImageIcon = Resource.Drawable.inbox_message;
```

<Aside type="note">
有关更多详细信息，请查看 Inbox 示例 [https://github.com/Pushwoosh/pushwoosh-xamarin/tree/master/Samples/Droid](https://github.com/Pushwoosh/pushwoosh-xamarin/tree/master/Samples/Droid)
</Aside>

## 与我们分享您的反馈

您的反馈有助于我们创造更好的体验，因此如果您在 SDK 集成过程中遇到任何问题，我们很乐意听取您的意见。如果您遇到任何困难，请随时 [通过此表单](https://docs.google.com/forms/d/e/1FAIpQLSd\_0b8jwn-V\_JmoPLIxIFYbHACCQhrzidOZV3ELywoQPXRSxw/viewform) 与我们分享您的想法。