{"id":25399508,"url":"https://github.com/appmetrica/push-sdk-ios","last_synced_at":"2025-07-10T20:37:31.439Z","repository":{"id":233537717,"uuid":"682053259","full_name":"appmetrica/push-sdk-ios","owner":"appmetrica","description":"AppMetrica Push SDK for iOS","archived":false,"fork":false,"pushed_at":"2025-01-14T11:39:08.000Z","size":136,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-14T12:23:17.079Z","etag":null,"topics":["appmetrica","ios","library","push"],"latest_commit_sha":null,"homepage":"https://appmetrica.io","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appmetrica.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-23T10:37:59.000Z","updated_at":"2025-01-14T11:39:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"be69adb0-1a76-4b7b-bc43-2a55ac8d466e","html_url":"https://github.com/appmetrica/push-sdk-ios","commit_stats":null,"previous_names":["appmetrica/push-sdk-ios"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmetrica%2Fpush-sdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmetrica%2Fpush-sdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmetrica%2Fpush-sdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appmetrica%2Fpush-sdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appmetrica","download_url":"https://codeload.github.com/appmetrica/push-sdk-ios/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239069977,"owners_count":19576466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appmetrica","ios","library","push"],"created_at":"2025-02-15T23:38:12.572Z","updated_at":"2025-02-15T23:38:13.302Z","avatar_url":"https://github.com/appmetrica.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [AppMetrica Push SDK](https://appmetrica.io)\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AppMetricaPush.svg?style=for-the-badge)](https://cocoapods.org/pods/AppMetricaPush)\n[![SPM Index Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fappmetrica%2Fpush-sdk-ios%2Fbadge%3Ftype%3Dswift-versions\u0026style=for-the-badge)](https://swiftpackageindex.com/appmetrica/push-sdk-ios)\n[![SPM Index Platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fappmetrica%2Fpush-sdk-ios%2Fbadge%3Ftype%3Dplatforms\u0026style=for-the-badge)](https://swiftpackageindex.com/appmetrica/push-sdk-ios)\n\nAppMetrica Push SDK allows you to send targeted push notifications to app users. These notifications are called push campaigns. You can use push campaigns to engage your audience and help reduce churn.\n\n## Installation\n\n### Swift Package Manager\n\n#### Through Xcode:\n\n1. Go to **File** \u003e **Add Package Dependency**.\n2. Put the GitHub link of the AppMetrica Push SDK: https://github.com/appmetrica/push-sdk-ios.\n3. In **Add to Target**, select **None** for modules you don't want.\n\n#### Via Package.swift Manifest:\n\n1. Add the SDK to your project's dependencies:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/appmetrica/push-sdk-ios\", from: \"3.0.0\")\n],\n```\n\n2. List the modules in your target's dependencies:\n\n```swift\n.target(\n    name: \"YourTargetName\",\n    dependencies: [\n        .product(name: \"AppMetricaPush\", package: \"push-sdk-ios\"),\n        // Optionally include 'AppMetricaPushLazy' for lazy push feature\n    ]\n)\n```\n\n### CocoaPods\n\n1. If you haven't set up CocoaPods, run `pod init` in your project directory.\n2. In your Podfile, add AppMetrica Push dependencies:\n\n```ruby\ntarget 'YourAppName' do\n    # For all analytics features, add this umbrella module:\n    pod 'AppMetricaPush', '~\u003e 3.0.0'\n\n    # Optionally add Lazy Push pod\n    pod 'AppMetricaPushLazy', '~\u003e 3.0.0'\nend\n```\n\n3. Install the dependencies using `pod install`.\n4. Open your project in Xcode with the `.xcworkspace` file.\n\n### Optional\n\n### Modules Overview\n\n- `AppMetricaPush`: Required for basic SDK use.\n- `AppMetricaPushLazy`: Enables lazy push support\n\n## Integration Quickstart\nHere's how to add AppMetrica Push SDK to your project (works for both SwiftUI and UIKit):\n\n1. Add [AppMetrica](https://github.com/appmetrica/appmetrica-sdk-ios/) into project\n\n2. `import AppMetricaPush`.\n\n3. If you are using notification service extension, set up [AppMetrica with shared AppGroup](https://appmetrica.io/docs/en/sdk/ios/analytics/ios-appgroup) and initialize AppMetrica in the extension.\n\n4. Configure AppMetricaPush by setting `UNUserNotificationCenter.current().delegate = AppMetricaPush.userNotificationCenterDelegate` in `application(_:didFinishLaunchingWithOptions:)`.\n\n5. Register device token in `application(_:didRegisterForRemoteNotificationsWithDeviceToken:)`\n\n6. Call `UIApplication.registerForRemoteNotifications()`. See [documentation](https://developer.apple.com/documentation/uikit/uiapplication/1623078-registerforremotenotifications) to enable visible notifications.\n\n7. (Optional) If you also use `UISceneDelegate` add `AppMetricaPush.handleSceneWillConnectToSession(with:)` in `scene(_:willConnectTo:options:)`\n\n### For UIKit:\n\nPut this in your `AppDelegate.swift`:\n\n```swift\nimport UIKit\nimport UserNotifications\nimport AppMetrica\nimport AppMetricaPush\n\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n\tfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -\u003e Bool {\n\t    if let configuration = AppMetricaConfiguration(apiKey: \"Your_API_Key\") {\n\t        AppMetrica.activate(with: configuration)\n\t    }\n\t    \n\t    UNUserNotificationCenter.current().delegate = AppMetricaPush.userNotificationCenterDelegate\n\t    return true\n\t}\n\t\n\tfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n\t    AppMetricaPush.setDeviceToken(deviceToken)\n\t}\n\n}\n```\n\nIf you are using scenes, put this in your `SceneDelegate.swift`\n```swift\nimport UIKit\nimport AppMetricaPush\n\nclass SceneDelegate: UIResponder, UIWindowSceneDelegate {\n\n\tfunc scene(_ scene: UIScene, willConnectTo\n\t           session: UISceneSession, options\n\t           connectionOptions: UIScene.ConnectionOptions) {\n\t     AppMetricaPush.handleSceneWillConnectToSession(with: connectionOptions)\n\t}\n}\n```\n\n### For SwiftUI:\n\nFor integrating AppMetrica Push SDK into a SwiftUI application, you can use an AppDelegate adapter to handle lifecycle events related to push notifications. Create a new AppDelegate.swift and set it up similarly to the UIKit approach:\n\n\nThen in your `App` struct:\n\n```swift\n@main\nstruct YourAppNameApp: App {\n    // Use the `@UIApplicationDelegateAdaptor` property wrapper to work with AppDelegate and set up AppMetrica Push SDK\n    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n        }\n    }\n}\n```\n\n## Notification Service Extension\n\nIf you are using notification service extension, put this in your `NotificationService.swift`\n```Swift\nclass NotificationService: UNNotificationServiceExtension {\n    var contentHandler: ((UNNotificationContent) -\u003e Void)?\n    var bestAttemptContent: UNMutableNotificationContent?\n\n    override func didReceive(_ request: UNNotificationRequest, \n                             withContentHandler contentHandler: @escaping (UNNotificationContent) -\u003e Void) {\n    // system does not always spawn new process to handle few notification, but AppMetrica ignore second initialization\n    let configuration = AppMetricaConfiguration(apiKey: \"API-KEY\")!\n    AppMetrica.activate(with: configuration)\n    \n    self.contentHandler = contentHandler\n    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)\n\n    // custom logic\n\n    AppMetrica.sendEventsBuffer()\n}\n```\n\n## Documentation\n\nYou can find comprehensive integration details and instructions for installation, configuration, testing, and more in our [full documentation](https://appmetrica.io/docs/en/push/).\n\n## License\n\nAppMetrica Push SDK is released under the MIT License.\nLicense agreement is available at [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappmetrica%2Fpush-sdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappmetrica%2Fpush-sdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappmetrica%2Fpush-sdk-ios/lists"}