حزمة تطوير برامج (SDK) لإشعارات iOS الفورية

How to Use an iOS Push Notifications SDK for Your App (With Code)

An iOS push notifications SDK does two jobs: it handles the plumbing between your app and Apple Push Notification service, and it connects that plumbing to a campaign platform so your marketing team can actually use it. This guide covers both — the real integration steps with the code you’ll ship, and what becomes possible in the dashboard once the SDK is in. It reflects the PushEngage iOS SDK 1.0, the current release.

Why use an iOS push notifications SDK for your app

You can talk to APNs directly — register for a device token, build a sender, handle delivery callbacks yourself. What you get from raw APNs is delivery; what you don’t get is everything marketing needs: segmentation, scheduled and triggered campaigns, A/B testing, analytics, and revenue attribution. An SDK like PushEngage’s wires your app into that layer once, so campaigns are created in a dashboard instead of an Xcode project. The practical result: after integration week, push campaigns stop being engineering tickets.

How to install the PushEngage iOS push notifications SDK

You’ll need iOS 12+, Xcode 15+, an APNs key uploaded to your PushEngage dashboard, and about an afternoon. The SDK ships as two modules: PushEngage for your app target and PushEngageExtension for notification extension targets.

Step 1: Add the package

In Xcode, go to File → Add Package Dependencies and enter the repository URL — or use CocoaPods:

# Swift Package Manager
https://github.com/awesomemotive/pushengage-ios-sdk

# CocoaPods
target 'YourApp' do
  pod 'PushEngage', '~> 1.0.0'
end
target 'YourNotificationServiceExtension' do
  pod 'PushEngageExtension', '~> 1.0.0'
end

Step 2: Configure the App Group

Add the App Groups capability to your app target and every notification extension target, using the same group ID, and declare it in each target’s Info.plist:

<key>PushEngage_App_Group_Key</key>
<string>group.com.yourcompany.yourapp</string>

The app and its extensions share subscriber state through this container. Skipping it is the single most common integration mistake — without it, your extensions start blank on every delivery.

Step 3: Initialize and request permission

import PushEngage

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        PushEngage.setAppID(id: "YOUR_APP_ID")
        PushEngage.setInitialInfo(for: application, with: launchOptions)
        return true
    }
}

// Later, at a value moment — not on first launch:
PushEngage.requestNotificationPermission { granted, error in
    if granted { /* subscribed */ }
}

Where you put that permission call matters more than anything else in this guide — iOS grants you exactly one native prompt. The permission priming guide covers the soft-ask pattern that protects it.

How to send rich app push notifications for iOS

Images, action buttons, and custom sounds require a Notification Service Extension — a small target that intercepts each notification and attaches media before display. Add the target in Xcode, link PushEngageExtension to it, and forward the two lifecycle calls:

import PushEngageExtension

class NotificationService: UNNotificationServiceExtension {
    override func didReceive(_ request: UNNotificationRequest,
                             withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        PushEngageExtension.didReceiveNotificationExtensionRequest(request,
                                                                   bestContentHandler: contentHandler)
    }

    override func serviceExtensionTimeWillExpire() {
        // hand back the best content prepared so far
    }
}

From there, rich media is a dashboard feature: your marketing team attaches the product image or hero graphic when they build the campaign, and the extension renders it. No further app changes per campaign.

How to create personalized iOS push notifications

Personalization runs on what the SDK knows about each subscriber. Identify your user and attach attributes, and every campaign can segment and template against them:

// Identify the signed-in user (12 predefined fields supported)
PushEngage.identify(fields: [
    "first_name": "Priya",
    "email": "[email protected]",
    "profile_id": "user-42",
    "city": "Austin"
]) { success, error in }

// Attach custom attributes for segmentation
PushEngage.addSubscriberAttributes([
    "favorite_category": "outerwear",
    "loyalty_tier": "gold"
]) { success, error in }

// On sign-out, clear PII but keep the anonymous subscription
PushEngage.logout(fieldNames: nil) { success, error in }

Repeat identify calls with unchanged data short-circuit locally, so calling it on every launch is safe. Once attributes flow, segmentation happens in the dashboard — “gold-tier outerwear shoppers in Texas” becomes a saved audience, not a SQL request.

How to add a deep link in iOS push notifications

Every campaign tap should land on the screen it promised. Set the notification open handler once, route on the deep link it carries:

PushEngage.setNotificationOpenHandler { result in
    // actionID is nil when the SDK already opened the URL itself
    guard let deepLink = result.notificationAction.actionID else { return }
    DispatchQueue.main.async {
        router.navigate(to: deepLink)   // e.g. myapp://cart
    }
}

The marketer pastes the deep link into the campaign form; your handler does the routing. Full patterns — including universal links and the auto-open option — are in the deep linking guide.

How to trigger campaigns from app events

The 1.0 SDK’s trackEvent call turns any in-app behavior into a campaign trigger — an abandoned cart, a completed onboarding step, a browsed category:

PushEngage.trackEvent(name: "cart_updated",
                      properties: ["cart_value": 89.50, "item_count": 2],
                      profileId: currentUserId,
                      provider: nil, eventType: nil) { _, _ in }

Instrument the event once; marketing builds and iterates the campaigns against it indefinitely. The event-triggered campaigns guide has the full taxonomy and the cart, onboarding, and win-back wiring.

What to do now that you have an iOS push notifications SDK

Integration is the beginning, not the finish line. The sequence that pays off fastest: protect your opt-in rate with a primed permission flow, ship the cart abandonment sequence (the highest-ROI campaign for commerce apps), add goal tracking so every campaign reports revenue instead of opens, and then build out the lifecycle — onboarding series on the front end, win-back on the back end. The app push marketing guide covers that strategy layer end to end, and the setup documentation walks every dashboard screen. Every paid plan carries a 14-day money-back guarantee — and the SDK is MIT-licensed on GitHub, so you can read exactly what you’re shipping.

أضف تعليقًا

يسعدنا أنك اخترت ترك تعليق. يرجى الأخذ في الاعتبار أن جميع التعليقات تخضع للإشراف وفقًا لسياسة الخصوصية الخاصة بنا، وجميع الروابط هي nofollow. لا تستخدم الكلمات الرئيسية في حقل الاسم. دعونا نجري محادثة شخصية وهادفة.

تفاعل مع الزوار واحتفظ بهم بعد مغادرة موقعك

زد قيمة كل زيارة ويب باستخدام إشعارات الدفع التي يصعب تفويتها.

  • خطة مجانية دائمة
  • إعداد سهل
  • دعم 5 نجوم