https://github.com/lambiengcode/flutter-ios-communication-notifications-plugin
Flutter plugin for displaying iOS communication notifications. Easily integrate notifications into your Flutter app. Compatible with iOS 15 and above.
https://github.com/lambiengcode/flutter-ios-communication-notifications-plugin
Last synced: 15 days ago
JSON representation
Flutter plugin for displaying iOS communication notifications. Easily integrate notifications into your Flutter app. Compatible with iOS 15 and above.
- Host: GitHub
- URL: https://github.com/lambiengcode/flutter-ios-communication-notifications-plugin
- Owner: lambiengcode
- License: mit
- Created: 2023-02-07T03:30:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-01T07:19:14.000Z (over 2 years ago)
- Last Synced: 2026-02-06T14:22:51.102Z (about 1 month ago)
- Language: Dart
- Homepage: https://pub.dev/packages/ios_communication_notification
- Size: 2.38 MB
- Stars: 10
- Watchers: 1
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## iOS Communication Notifications
- Ref: [Apple Docs](https://developer.apple.com/documentation/usernotifications/implementing_communication_notifications)
## Screenshots:
- Config XCode
> Capabilities
1. Open your Project in XCode.
2. Click on `Runner`, then Target `Runner`
3. Click on Signing & Capabilities
4. Add Capability
5. Add Communication Notifications
> Info.plist
1. Open `Info.plist`
2. Add `NSUserActivityTypes` as type array
3. Add `INSendMessageIntent` as the element of the newly created array
- Config AppDelegate Extension
1. Open `AppDelegate.swift`
2. Copy the below piece of code and add it at the end of the file
```swift
import UIKit
import ios_communication_notification
extension AppDelegate {
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if #available(iOS 15.0, *) {
if (notification.request.identifier.starts(with: IosCommunicationConstant.prefixIdentifier)) {
completionHandler([.banner, .badge, .sound, .list])
}
}
return super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if #available(iOS 15.0, *) {
if (response.notification.request.identifier.starts(with: IosCommunicationConstant.prefixIdentifier)) {
let userInfo = response.notification.request.content.userInfo
IosCommunicationNotificationPlugin.shared.onClickNotification(userInfo)
completionHandler()
}
}
return super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
}
```
## Usage
- Check available for show communication notifications
```dart
// if iOS 15 or above
final bool isAvailableForCommunication = await IosCommunicationNotification().isAvailable();
```
- Show notification
```dart
IosCommunicationNotification().showNotification(
NotificationInfo(
senderName: "lambiengcode",
imageBytes: imageBuffer,
value: "This is payload, will receive when click this notification",
content: "Hello Flutter"
),
);
```
- Get initial payload - useful for check and get payload if app start from click communication notification
```dart
IosCommunicationNotification().getInitialPayload().then((payload) {
// TODO: do somethings
});
```
- Set onClick callback function
```dart
IosCommunicationNotification().setOnClickNotification((payload) {
// TODO: do somethings
});
```
### ReactionBoxParamenters
| parameter | description | default |
| -------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| senderName | Title of notification - sender message notification |required|
| imageBytes | Avatar of sender |required|
| content | Message content | required |
| value | Payload notification | required |
## Download Askany
## License - lambiengcode
```terminal
MIT License
Copyright (c) 2022 Askany
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

