{"id":1680,"url":"https://github.com/facebookarchive/FBNotifications","last_synced_at":"2025-08-02T04:32:24.522Z","repository":{"id":50356635,"uuid":"55754986","full_name":"facebookarchive/FBNotifications","owner":"facebookarchive","description":"Facebook Analytics In-App Notifications Framework","archived":true,"fork":false,"pushed_at":"2019-03-27T22:28:35.000Z","size":317,"stargazers_count":494,"open_issues_count":22,"forks_count":82,"subscribers_count":35,"default_branch":"master","last_synced_at":"2024-05-29T04:49:12.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developers.facebook.com/products/push-campaigns","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facebookarchive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-Android.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-08T06:14:31.000Z","updated_at":"2024-01-04T16:04:05.000Z","dependencies_parsed_at":"2022-08-20T20:20:48.049Z","dependency_job_id":null,"html_url":"https://github.com/facebookarchive/FBNotifications","commit_stats":null,"previous_names":["facebook/fbnotifications"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2FFBNotifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2FFBNotifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2FFBNotifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2FFBNotifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facebookarchive","download_url":"https://codeload.github.com/facebookarchive/FBNotifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228439110,"owners_count":17920018,"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":[],"created_at":"2024-01-05T20:15:53.159Z","updated_at":"2024-12-06T08:31:30.412Z","avatar_url":"https://github.com/facebookarchive.png","language":"Objective-C","funding_links":[],"categories":["Notifications","Objective-C"],"sub_categories":["Push Notifications"],"readme":"![FBNotifications logo](.github/FBNotifications-Logo.png?raw=true)\n\n![Platforms][platforms-svg]\n[![Build Status][build-status-svg]][build-status-link]\n\nFacebook In-App Notifications enables you to create rich and customizable in-app notifications and deliver them via push notifications, based on the actions people take in your app. You can use text, photos, animated GIFs, buttons or extend the open format to suit your needs.\n\n## Getting Started on iOS\n\n[![Podspec][podspec-svg]][podspec-link]\n[![Carthage compatible][carthage-svg]](carthage-link)\n\nTo get started on iOS, install the framework using one of these options:\n\n- **[CocoaPods](https://cocoapods.org)**\n\n Add the following line to your Podfile:\n ```ruby\n pod 'FBNotifications'\n ```\n Run `pod install`, and you should now have the latest framework installed.\n\n- **[Carthage](https://github.com/carthage/carthage)**\n\n Add the following line to your Cartfile:\n ```\n github \"facebook/FBNotifications\"\n ```\n Run `carthage update`, and you should now have the latest version of the framework in your Carthage folder.\n\nAfter you've installed the framework, you would need to add the following to your application delegate to present the notification:\n\nUsing *Objective-C*:\n\n```objc\n/// Present In-App Notification from remote notification (if present).\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler {\n  FBNotificationsManager *notificationsManager = [FBNotificationsManager sharedManager];\n  [notificationsManager presentPushCardForRemoteNotificationPayload:userInfo\n                                                 fromViewController:nil\n                                                         completion:^(FBNCardViewController * _Nullable viewController, NSError * _Nullable error) {\n                                                           if (error) {\n                                                             completionHandler(UIBackgroundFetchResultFailed);\n                                                           } else {\n                                                             completionHandler(UIBackgroundFetchResultNewData);\n                                                           }\n                                                         }];\n}\n```\n\nUsing *Swift*:\n```swift\n/// Present In-App Notification from remote notification (if present).\nfunc application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -\u003e Void) {\n  FBNotificationsManager.sharedManager().presentPushCardForRemoteNotificationPayload(userInfo, fromViewController: nil) { viewController, error in\n    if let _ error = error {\n      completionHandler(.Failed)\n    } else {\n      completionHandler(.NewData)\n    }\n  }\n}\n```\n\n## Getting Started on Android\n\n[![Maven Central][maven-svg]][maven-link]\n\nTo get started on Android, add the following to your gradle dependencies:\n\n```gradle\ncompile 'com.facebook.android:notifications:1.+'\n```\n\nAfter you've added the dependency, you'll have to [set up an FCM listener service](https://firebase.google.com/docs/cloud-messaging/android/client), and add the following to your service:\n\n```java\n@Override\npublic void onMessageReceived(RemoteMessage remoteMessage) {\n    Bundle data = new Bundle();\n    for (Map.Entry\u003cString, String\u003e entry : remoteMessage.getData().entrySet()) {\n      data.putString(entry.getKey(), entry.getValue());\n    }\n  \n    NotificationsManager.presentNotification(\n        this,\n        data,\n        new Intent(getApplicationContext(), MainActivity.class)\n    );\n}\n```\n\nThen when all the content for the notification is ready - it will automatically present the notification to the end user with a pending intent to present a card on open.\nTo hand-off the necessary data from the intent - you need to handle the notification in the `onCreate` function of your Main Activity:\n\n```java\npublic class MainActivity extends AppCompatActivity {\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    NotificationsManager.presentCardFromNotification(this);\n  }\n}\n```\n\nFor more help on getting started, take a look at our [Facebook Push Campaigns Documentation](https://developers.facebook.com/docs/push-campaigns).\n\n## In-App Notifications Format\n\nIn-app notifications are powered by a custom format that has an open specification available in this repository.\nThe format describes all the possible values and combinations of content that can be rendered by the framework.\n\nWe are open to accepting contributions to the format and the format is constantly evolving.\nAny version of the framework is compatible with any previous version of the format in the same major version scope.\n\nFor example:\n  - Framework `1.0.0` **is** compatible with format version `1.0`\n  - Framework `1.0.0` **is not** compatible with format version `1.5`\n  - Framework `1.5.0` **is** compatible with format version `1.5`\n  - Framework `1.5.1` **is** compatible with format version `1.5`\n  - Framework `2.0.0` **is not** compatible with format version `1.0`, or `1.5`\n\n## Contributing\n\nWe want to make contributing to this project as easy and transparent as possible. Please refer to the [Contribution Guidelines](https://github.com/facebook/FBNotifications/blob/master/CONTRIBUTING.md).\n\n## License\n\nSee the `LICENSE` file for source code.\nSee the `LICENSE-specification` file for In-App Notifications format specification.\n\n [platforms-svg]: https://img.shields.io/badge/platform-iOS%20%7C%20Android-lightgrey.svg\n\n [build-status-svg]: https://img.shields.io/travis/facebook/FBNotifications/master.svg\n [build-status-link]: https://travis-ci.org/facebook/FBNotifications/branches\n\n [podspec-svg]: https://img.shields.io/cocoapods/v/FBNotifications.svg\n [podspec-link]: https://cocoapods.org/pods/FBNotifications\n\n [carthage-svg]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\n [carthage-link]: https://github.com/carthage/carthage\n\n [maven-svg]: https://maven-badges.herokuapp.com/maven-central/com.facebook.android/notifications/badge.svg?style=flat\n [maven-link]: https://maven-badges.herokuapp.com/maven-central/com.facebook.android/notifications\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookarchive%2FFBNotifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacebookarchive%2FFBNotifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookarchive%2FFBNotifications/lists"}