{"id":21658668,"url":"https://github.com/wumke/react-native-local-notifications","last_synced_at":"2025-04-03T06:19:02.585Z","repository":{"id":57125653,"uuid":"79131186","full_name":"wumke/react-native-local-notifications","owner":"wumke","description":"Manageable local notifications for React Native on iOS and Android.","archived":false,"fork":false,"pushed_at":"2020-02-12T07:39:46.000Z","size":867,"stargazers_count":84,"open_issues_count":7,"forks_count":33,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T18:05:23.073Z","etag":null,"topics":["react-native"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/wumke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-16T15:22:24.000Z","updated_at":"2023-11-22T19:04:44.000Z","dependencies_parsed_at":"2022-08-31T08:11:44.940Z","dependency_job_id":null,"html_url":"https://github.com/wumke/react-native-local-notifications","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wumke%2Freact-native-local-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wumke%2Freact-native-local-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wumke%2Freact-native-local-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wumke%2Freact-native-local-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wumke","download_url":"https://codeload.github.com/wumke/react-native-local-notifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246944386,"owners_count":20858772,"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":["react-native"],"created_at":"2024-11-25T09:29:38.263Z","updated_at":"2025-04-03T06:19:02.562Z","avatar_url":"https://github.com/wumke.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# react-native-local-notifications\nManageable local notifications for React Native on iOS and Android. Create, update and delete local notifications by their unique id. The push notification title is the app name. When you open the app all displayed local notifications will be removed and the badge counter will be reset on iOS. \n\nNOTICE:\n- for React Native \u003c 0.47 use react-native-local-notifications \u003c1.x.x\n- for React Native \u003e 0.47 use react-native-local-notifications \u003e=1.x.x\n- for Android API lvl \u003e=19 use react-native-local-notifications \u003e=2.x.x\n\nNOTIFICATIONS WILL NOT BE SHOWN WHEN YOUR APP IS IN THE FOREGROUND. (options to handle this situation might be added in future releases)\n\nFor latest Android versions, please check notification settings and battery management settings if notifications are not shown at the specified time. This libary aims to deliver exact notifications, which are not delayed by the system.\nCreating a never ending back- or foregroundservice (API lvl \u003e=26) can help stopping the device to kill your apps and not show your notifications on exact times. \nAlso see https://dontkillmyapp.com for more info and tips to solve this problem for devices with custom battery saving packages.\n\n## Setup\n\nFast and easy:\n```bash\nnpm install react-native-local-notifications --save\nreact-native link react-native-local-notifications\n```\nKeep in mind that the link step only links the project in the native projects, more steps have to be done for both platforms, which are described in the Android and iOS section below... please verify manually that the link command successfully linked the libray to your project!\n\nOr manual: add the latest version as dependeny to your package.json.\n\n```javascript\n{\n  \"name\": \"YourProject\",\n  ...\n  },\n  \"dependencies\": {\n    ...\n    \"react-native-local-notifications\": \"2.0.0\",\n    ...\n  }\n```\n\n#### iOS\n* {auto-link} Add RNLocalNotifications.xcoderproj into your project in the Libraries folder.\n* {auto-link}Add the .a file on the General tab of your target under Linked Frameworks And Libraries\n* {auto-link}Add the .a file on the Build Phases tab of your target under Link Binary With Libraries\n* In the AppDelegate.m file of your xcode project add: (this will clear all notifications when you open the app)\n    ```\n    - (void)applicationDidBecomeActive:(UIApplication *)application\n    {\n      [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; //Allways reset number of notifications shown at the icon\n      for (UILocalNotification * notification in [[UIApplication sharedApplication] scheduledLocalNotifications]) { //Also remove all shown notifications\n        if ([notification.fireDate compare:[NSDate date]] == NSOrderedAscending) {\n          [[UIApplication sharedApplication] cancelLocalNotification:notification];\n        }\n      }\n    }\n    ```\n* In the AppDelegate.m file of your xcode project, in the didFinishLaunchingWithOptions function, add: (ask the user to allow notifications)\n    ```\n    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {\n        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeSound categories:nil]];\n      }\n  ```\n* Add Alarm.caf and Silence.caf to the Resources folder of your xcode project. (can be found in react-native-local-notifications/ios/RNLocalNotifications)\n\n#### Android\n* In the AndroidManifest.xml file of your android studio project add:\n    ```\n    \u003creceiver android:process=\":remote\" android:name=\"com.github.wumke.RNLocalNotifications.AlarmReceiver\" android:exported=\"true\"\u003e\u003c/receiver\u003e\n    ```\n* In the MainActivity.java file of your android studio project add: (this will clear all notifications when you open the app)\n  ```\n  import android.content.Context;\n  import android.app.NotificationManager;\n  ...\n  @Override\n      public void onResume() {\n          super.onResume();\n          NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\n          nMgr.cancelAll();\n      }\n  ```\n* {auto-link}In the settings.gradle\n  ```\n    include ':react-native-local-notifications', ':app'\n    project(':react-native-local-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-local-notifications/android')\n  ```\n* {auto-link}In the build.gradle\n  ```\n    compile project(':react-native-local-notifications')\n  ```\n* {auto-link}In MainApplication.java\n  ```\n    import com.github.wumke.RNLocalNotifications.RNLocalNotificationsPackage;\n    ...\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n      return Arrays.\u003cReactPackage\u003easList(\n        ...\n        new RNLocalNotificationsPackage(),\n        ...\n      );\n    }\n    ...\n  ```\n * Aside from the big icon, for which the ic_launcher icon in mipmap folder is used by default, you also need a small transparent with white foreground icon which will be displayed in the status bar.\n See Android developer specifications for correct sizes, by default 'notification_small' from the drawable folder is used... \n  \n## Usage\n\n####Examples:\n```javascript\nimport RNLocalNotifications from 'react-native-local-notifications';\n...\n//RNLocalNotifications.setAndroidIcons(largeIconName, largeIconType, smallIconName, smallIconType);\nRNLocalNotifications.setAndroidIcons(\"ic_launcher\", \"mipmap\", \"notification_small\", \"drawable\"); //this are the default values, this function is optional\n\n//RNLocalNotifications.createNotification(id, text, datetime, sound[, hiddendata]);\nRNLocalNotifications.createNotification(1, 'Some text', '2017-01-02 12:30', 'default');\n\n//RNLocalNotifications.updateNotification(id, text, datetime, sound[, hiddendata]);\nRNLocalNotifications.updateNotification(1, 'Some modifications to text', '2017-01-02 12:35', 'silence');\n\n//RNLocalNotifications.deleteNotification(id);\nRNLocalNotifications.deleteNotification(1);\n...\n```\n#### Parameter explanation:\n* id (Integer): Unique value to be able to edit or cancel scheduled notifications.\n* text (String): The message text.\n* datetime (String): The date + time to show the notification, as a string in the format 'yyyy-mm-dd hh:mm'.\n* sound (String): Which sound is played: '' or 'silence' for vibration only, 'default' for system alarm sound, custom sound namefor self added ringtones.\n* hiddendata (String): Invisible data that can be used to perform custom actions when the mobile app is opened by clicking on the local notification.\n\n#### Add custom sounds:\n\nConvert your ringtone to .caf and .mp3 file formats.\n\n__iOS__: Add yoursound.caf to the Resources folder of your xcode project.  \n__Android__: Add yoursound.mp3 to the 'raw' folder\n\nUse 'yoursound' as string for the sound parameter.\n\n#### Hidden/extra data:\n\nWhen you need to include custom, non-visible, data (for example object id's) to your notifications provide the optional 'hiddendata' parameter to createNotification/updateNotification.\n\nThe value will be available as hiddendata (Android) or userData.hiddendata (iOS) when you click the notification.\n\nNote that 'hiddendata' must be a string, so if you want to include json objects you need to encode/decode the data yourself.\n\n## Versioning\n\nThis project uses semantic versioning: MAJOR.MINOR.PATCH.\nThis means that releases within the same MAJOR version are always backwards compatible. For more info see [semver.org](http://semver.org/).\n\n## Licence\n\nMIT (see LICENCE file)\n\n## Release notes\n\nSee https://www.npmjs.com/package/react-native-local-notifications?activeTab=versions\n\n#### 2.0.0\n\nBreaking changes\n- none\n\nNew features / Updates\n- Changed licence to MIT\n- Custom sounds\n- Hidden data\n- Set Android notification icons type/name\n- compileSdkVersion, buildToolsVersion and targetSdkVersion (equal to compileSdkVersion)\n\nFixes\n- Readme delete notification example\n- Updated android part to schedule exact notifications based on api lvl for api lvl 19, 21 and 23 (tested up to 26)\n- Added com.android.support:support-v4:+ dependency\n\nTodo\n- iOS UILocalNotification deprecation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwumke%2Freact-native-local-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwumke%2Freact-native-local-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwumke%2Freact-native-local-notifications/lists"}