Mimo.AppStoreServerLibrary
0.0.1
See the version list below for details.
dotnet add package Mimo.AppStoreServerLibrary --version 0.0.1
NuGet\Install-Package Mimo.AppStoreServerLibrary -Version 0.0.1
<PackageReference Include="Mimo.AppStoreServerLibrary" Version="0.0.1" />
paket add Mimo.AppStoreServerLibrary --version 0.0.1
#r "nuget: Mimo.AppStoreServerLibrary, 0.0.1"
// Install Mimo.AppStoreServerLibrary as a Cake Addin #addin nuget:?package=Mimo.AppStoreServerLibrary&version=0.0.1 // Install Mimo.AppStoreServerLibrary as a Cake Tool #tool nuget:?package=Mimo.AppStoreServerLibrary&version=0.0.1
App Store Server Library for .NET
An unofficial .NET SDK for App Store Server Notifications v2 and API
The overall library and API design is copied from the official Apple libraries and it is intended to be used in the same way. More resources:
Features
This is a list of the features that are currently implemented in the library, compared to the official Apple libraries.
Feature | Apple | This library |
---|---|---|
Verify and decode notifications | ✅ | ✅ |
Verify and decode transactions | ✅ | ✅ |
Verify and decode renewal infos | ✅ | ✅ |
Generate API Token | ✅ | ✅ |
Get All Subscription Statuses | ✅ | ✅ |
Get Notification History | ✅ | ✅ |
Get Transaction History v2 | ✅ | ✅ |
Extract Transaction Id from receipt | ✅ | ✅ |
Get Transaction History v1 | ✅ | |
Get Transaction Info | ✅ | |
Send Consumption Information | ✅ | ✅ |
Look Up Order ID | ✅ | |
Get Refund History | ✅ | |
Extending the renewal date for auto-renewable subscriptions | ✅ | |
Request a Test Notification | ✅ |
Installation
The library is available on NuGet. You can install it using the following command:
dotnet add package Mimo.AppStoreServerLibrary
Usage
Obtaining Apple Root Certificates
Download and store the root certificates found in the Apple Root Certificates section of the Apple PKI site. Provide these certificates as an array to a SignedDataVerifier to allow verifying the signed data comes from Apple.
Notification Verification
Here is an example of how to verify a notification:
var signedDataVerifier = new SignedDataVerifier(
appleRootCertificates: rootCertificatesBytes,
enableOnlineChecks: true,
environment: AppStoreEnvironment.Sandbox,
bundleId: "com.example.app"
);
try {
var decodedPayload = await signedDataVerifier.VerifyAndDecodeNotification(signedPayload);
} catch (VerificationException ex) {
Console.WriteLine($"Verification failed: {ex.Message}");
}
[!IMPORTANT]
TheSignedDataVerifier
will not verify the payload if theenvironment
parameter isLocalTesting
. This was done to allow testing fake payloads locally without the need to verify them.
API
Here is an example of how to get all notification history for a specific transaction using the Pagination token
:
// Create a request for notification history
NotificationHistoryRequest request = new()
{
StartDate = DateTimeOffset.UtcNow.AddDays(-7).ToUnixTimeMilliseconds(),
EndDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
// Optional: filter by transaction ID
TransactionId = "your-transaction-id"
};
// Get initial page of notifications
NotificationHistoryResponse? notifications =
await appStoreServerClient.GetNotificationHistory(request);
if (notifications != null)
{
// Process notifications on current page
foreach (var notification in notifications.NotificationHistory)
{
Console.WriteLine($"Notification ID: {notification.SignedPayload}");
}
// Get additional pages if they exist
while (notifications.HasMore)
{
notifications = await appStoreServerClient.GetNotificationHistory(
request,
notifications.PaginationToken
);
foreach (var notification in notifications!.NotificationHistory)
{
Console.WriteLine($"Notification ID: {notification.SignedPayload}");
}
}
}
Receipt Utility
Here is an example of how to extract the transaction id from a receipt:
string receiptData = "your-receipt-data";
ReceiptUtility utility = new();
string transactionId = utility.ExtractTransactionIdFromAppReceipt(receiptData);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.1)
- Microsoft.IdentityModel.Tokens (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.