Skip to main content

Ios Uninstall Tracking (APN)

Overview

Track app uninstalls using Apple Push Notification Service (APNs) to measure user retention and optimize your campaigns.

info

iOS uninstalls take 9+ days to appear in reports due to Apple Push Notification service.


Prerequisites

  • iOS 10.0 or higher
  • Xcode 12.0 or later
  • Apple Developer Account
  • Apptrove Flutter SDK version 1.6.79+ installed

Step 1: Request Certificate in Keychain Access

1.1. Open Keychain Access on your Mac.

1.2. Go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.

Request Certificate

1.3. Fill in the form:

  • User Email Address: Your email
  • Common Name: Your name
  • Request is: Select Saved to disk
  • Click Continue

1.4. Save the file to your Desktop.

Save to Disk


Step 2: Go to Apple Developer Portal - Identifiers

2.1. Open Apple Developer Portal.

2.2. Go to Certificates, Identifiers & Profiles.

2.3. Click Identifiers.

2.4. Select your App ID (your app's bundle ID/package name).

Identifiers


Step 3: Configure Push Notifications

3.1. After clicking your App ID, you'll see the App ID Configuration page.

3.2. Scroll to Capabilities section.

3.3. Check Push Notifications.

3.4. Click Configure.

Push Notifications Configuration


Step 4: Upload Certificate and Download .cer

4.1. In the Push Notifications configuration screen, choose:

  • Production SSL Certificate (for App Store/Production)
  • Click Create Certificate

4.2. Click Choose File and upload the .certSigningRequest file from Step 1.

4.3. Click Continue.

4.4. Click Download to save the .cer file.

Download .cer Certificate


Step 5: Go to Keychain and Export as .p12

5.1. Double-click the downloaded .cer file to open it in Keychain Access.

5.2. In Keychain Access, click My Certificates in the left sidebar.

5.3. Find your Push Notification certificate (e.g., "Apple Push Services: com.yourapp.package").

5.4. Right-click on the certificate → Select Export.

5.5. Save as:

  • File Format: Personal Information Exchange (.p12)
  • Enter a password (you will need this later)
  • Click Save

Export .p12 Certificate


Step 6: Upload .p12 to Apptrove Panel

6.1. Log in to your Apptrove Panel.

6.2. Go to Settings > Uninstall Tracking.

6.3. Select your iOS app.

6.4. Click Upload and select the .p12 file.

6.5. Enter the password you created in Step 5.

6.6. Click Save.


Step 7: Configure in Xcode

7.1. Open your project in Xcode.

7.2. Select your app TargetSigning & Capabilities tab.

7.3. Click + Capability → Add Push Notifications.

7.4. Click + Capability again → Add Background Modes.

7.5. Check Remote notifications.

Background Modes


Step 8: Add User Permission in Info.plist

8.1. Open your project in Xcode.

8.2. Open the Info.plist file.

8.3. Add the following key and description:

Key: NSUserNotificationsUsageDescription

Value: We need permission to send you notifications and track uninstalls.

You can also add it in the Source Code view:

<key>NSUserNotificationsUsageDescription</key>
<string>We need permission to send you notifications and track uninstalls.</string>
note

This permission message will be shown to users when your app requests notification access.


Step 9: Send Token to Trackier SDK

Add this code to your Flutter app's main.dart:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:trackier_flutter_sdk/trackier_flutter_sdk.dart';
import 'firebase_options.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(MyApp());
}

class MyApp extends StatefulWidget {

_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

void initState() {
super.initState();
_initializeTrackierSDK();
}

Future<void> _initializeTrackierSDK() async {
// Initialize Trackier SDK
TrackierSDKConfig trackerSDKConfig = TrackierSDKConfig(
"YOUR_SDK_KEY",
"production"
);

Trackierfluttersdk.initializeSDK(trackerSDKConfig);

// Initialize APNs token for iOS
if (Platform.isIOS) {
await _getAndSendApnsToken();
}
}

/// Get and send APNs token for iOS
Future<void> _getAndSendApnsToken() async {
if (!Platform.isIOS) {
return;
}

try {
final messaging = FirebaseMessaging.instance;

// Request notification permissions
NotificationSettings settings = await messaging.requestPermission(
alert: true,
badge: true,
sound: true,
);

if (settings.authorizationStatus == AuthorizationStatus.authorized) {
print('Notification permission granted, getting APNs token...');
} else {
print('Notification permission denied: ${settings.authorizationStatus}');
}

// Get APNs token with retry logic
String? apnsToken;
int retryCount = 0;
const maxRetries = 3;
const retryDelay = Duration(seconds: 2);

while (apnsToken == null && retryCount < maxRetries) {
try {
apnsToken = await messaging.getAPNSToken();
print('APNs Token attempt ${retryCount + 1}: ${apnsToken ?? 'null'}');
} catch (e) {
print('Error getting APNs token: $e');
}

if (apnsToken == null) {
retryCount++;
if (retryCount < maxRetries) {
print('APNs token not ready, retrying in ${retryDelay.inSeconds}s...');
await Future.delayed(retryDelay);
}
}
}

if (apnsToken != null && apnsToken.isNotEmpty) {
print('Raw APNs Token: $apnsToken');

// Send to Trackier SDK
Trackierfluttersdk.sendAPNToken(apnsToken);
print('APNs Token sent to Trackier successfully');
} else {
print('Failed to get APNs token after $maxRetries retries (common on simulator; test on device)');
}
} catch (e) {
print('Error getting APNs token: $e');
}
}


Widget build(BuildContext context) {
return MaterialApp(
title: 'Your App',
home: Scaffold(
appBar: AppBar(title: Text('Trackier SDK')),
body: Center(child: Text('Trackier SDK Initialized')),
),
);
}
}

Step 10: Check Logs

Run your app on a physical device (Simulator doesn't support APNs).

Check Xcode console logs. You should see:

APN Token: b0adf7c9730763f88e1a048e28c68a9f806ed032fb522debff5bfba010a9b052
Apn token Api response saved successfully

Verify Logs

| Success: "Apn token Api response saved successfully"

| Error: If you see an error message, check the troubleshooting section below.


Troubleshooting

Issue: Token Not Generated

Check:

  • Push Notifications capability is enabled in Xcode
  • Testing on physical device (not Simulator)
  • User granted notification permission

Issue: "API Response Failed" Error

Check:

  • .p12 certificate uploaded to Apptrove panel
  • Password is correct
  • Using Production certificate for App Store builds
  • SDK is initialized before calling sendAPNToken

Issue: User Denied Notification Permission

Solution: User must enable in Settings > [Your App] > Notifications

Issue: Uninstalls Not Appearing in Dashboard

Remember: Takes 9+ days to appear for production builds.


Complete Flow Summary

  1. Keychain Access → Request Certificate → Save .certSigningRequest file
  2. Apple Developer Portal → Identifiers → Select your App ID
  3. Configure Push Notifications → Enable and click Configure
  4. Upload Certificate Request → Download .cer file
  5. Keychain Access → Export .cer as .p12 with password
  6. Apptrove Panel → Upload .p12 file + password
  7. Xcode → Enable Push Notifications + Background Modes
  8. Info.plist → Add user permission description
  9. Flutter App → Call Trackierfluttersdk.sendAPNToken(token)
  10. Check Logs → Verify "Apn token Api response saved successfully"

SDK Method

sendAPNToken(token)

Send the APN token to Apptrove for uninstall tracking.

Usage:

Trackierfluttersdk.sendAPNToken("your_apn_token_string");

When to call: After SDK initialization, in your Flutter app's initialization flow.


For support, contact support@trackier.com.