getui_flutter 1.0.0
getui_flutter: ^1.0.0 copied to clipboard
Enhanced Getui Flutter plugin with full payload support for push notifications. Fork of getuiflut with bug fixes and improvements.
getui_flutter #
Enhanced Getui (ไธชๆจ) Flutter plugin with full payload support for push notifications.
๐ฏ Why This Fork? #
This is an enhanced fork of the original getuiflut plugin with critical bug fixes:
โ Key Improvements #
- Fixed payload data loss:
onNotificationMessageArrivednow correctly receives full payload data on Android - Enhanced notification handling: Improved data transmission in notification callbacks
- Better error handling: More robust error handling in native code
- Updated documentation: Clearer examples and API documentation
๐ Original Issue #
In the original getuiflut plugin, when receiving push notifications on Android, the onNotificationMessageArrived callback would often receive null or incomplete payload data, making it impossible to handle custom notification data properly.
This fork fixes that issue completely.
๐ฆ Installation #
Add this to your pubspec.yaml:
dependencies:
getui_flutter: ^1.0.0
Then run:
flutter pub get
๐ Quick Start #
1. Android Setup #
Add Getui SDK dependency
In your android/app/build.gradle:
dependencies {
// Add Getui SDK
implementation 'com.getui:gtsdk:3.2.13.0' // Check for latest version
implementation 'com.getui:gtc:3.1.10.0'
}
Configure AndroidManifest.xml
<manifest>
<application>
<!-- Getui Configuration -->
<meta-data
android:name="PUSH_APPID"
android:value="YOUR_APP_ID" />
<meta-data
android:name="PUSH_APPKEY"
android:value="YOUR_APP_KEY" />
<meta-data
android:name="PUSH_APPSECRET"
android:value="YOUR_APP_SECRET" />
</application>
</manifest>
2. iOS Setup #
Add to Podfile
# ios/Podfile
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
# Add Getui SDK
pod 'GTSDK', '~> 3.0'
end
Then run:
cd ios && pod install
Initialize in AppDelegate
// ios/Runner/AppDelegate.swift
import UIKit
import Flutter
import GTSDK
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
// Initialize Getui
GeTuiSdk.start(withAppId: "YOUR_APP_ID",
appKey: "YOUR_APP_KEY",
appSecret: "YOUR_APP_SECRET",
delegate: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
3. Flutter Code #
import 'package:getui_flutter/getui_flutter.dart';
class PushService {
final GetuiFlutter _getuiPlugin = GetuiFlutter();
void initialize() {
// Initialize SDK
GetuiFlutter.initGetuiSdk;
// Add event handlers
_getuiPlugin.addEventHandler(
// Receive Client ID
onReceiveClientId: (String clientId) async {
print("Getui Client ID: $clientId");
},
// Receive notification message (when app is in foreground)
onNotificationMessageArrived: (Map<String, dynamic> message) async {
print("Notification arrived: $message");
// โ
Now you can access full payload data!
final payload = message['payload'];
final title = message['title'];
final content = message['content'];
print("Payload: $payload");
},
// Handle notification click
onNotificationMessageClicked: (Map<String, dynamic> message) async {
print("Notification clicked: $message");
// Handle navigation based on payload
final payload = message['payload'];
// Navigate to specific screen based on payload
},
// Receive transparent message
onReceiveMessageData: (Map<String, dynamic> message) async {
print("Transparent message: $message");
},
// iOS specific callbacks
onRegisterDeviceToken: (String token) async {
print("Device token: $token");
},
onReceivePayload: (Map<String, dynamic> payload) async {
print("iOS payload: $payload");
},
onReceiveNotificationResponse: (Map<String, dynamic> response) async {
print("iOS notification response: $response");
},
onAppLinkPayload: (String payload) async {
print("App link payload: $payload");
},
onPushModeResult: (Map<String, dynamic> result) async {
print("Push mode result: $result");
},
onSetTagResult: (Map<String, dynamic> result) async {
print("Set tag result: $result");
},
onAliasResult: (Map<String, dynamic> result) async {
print("Alias result: $result");
},
onQueryTagResult: (Map<String, dynamic> result) async {
print("Query tag result: $result");
},
onWillPresentNotification: (Map<String, dynamic> notification) async {
print("Will present notification: $notification");
},
onOpenSettingsForNotification: (Map<String, dynamic> settings) async {
print("Open settings: $settings");
},
onTransmitUserMessageReceive: (Map<String, dynamic> message) async {
print("User message: $message");
},
onGrantAuthorization: (String result) async {
print("Authorization: $result");
},
onLiveActivityResult: (Map<String, dynamic> result) async {
print("Live activity result: $result");
},
);
}
// Get client ID
Future<String> getClientId() async {
return await GetuiFlutter.getClientId;
}
// Bind alias
void bindAlias(String alias) {
_getuiPlugin.bindAlias(alias, "your_sequence_number");
}
// Unbind alias
void unbindAlias(String alias) {
_getuiPlugin.unbindAlias(alias, "your_sequence_number", true);
}
// Set badge (iOS)
void setBadge(int count) {
_getuiPlugin.setBadge(count);
}
// Set tags
void setTags(List<String> tags) {
_getuiPlugin.setTag(tags);
}
}
๐ API Reference #
Static Methods #
| Method | Return Type | Description | Platform |
|---|---|---|---|
initGetuiSdk |
Future<void> |
Initialize Getui SDK | Android, iOS |
getClientId |
Future<String> |
Get Getui client ID | Android, iOS |
sdkVersion |
Future<String> |
Get SDK version | Android, iOS |
getLaunchNotification |
Future<Map> |
Get notification that launched the app | Android, iOS |
platformVersion |
Future<String> |
Get platform version | Android, iOS |
Instance Methods #
| Method | Parameters | Description | Platform |
|---|---|---|---|
turnOnPush() |
- | Enable push notifications | Android, iOS |
turnOffPush() |
- | Disable push notifications | Android |
bindAlias() |
String alias, String sn |
Bind user alias | Android, iOS |
unbindAlias() |
String alias, String sn, bool isSelf |
Unbind user alias | Android, iOS |
setBadge() |
int badge |
Set app badge number | Android, iOS |
resetBadge() |
- | Reset badge to 0 | iOS |
setTag() |
List<dynamic> tags |
Set user tags | Android, iOS |
setPushMode() |
int mode |
Set push mode | iOS |
runBackgroundEnable() |
int enable |
Enable background running | iOS |
registerActivityToken() |
String aid, String token, String sn |
Register live activity token | iOS |
Event Handlers #
All event handlers are configured through addEventHandler():
| Handler | Parameter Type | Description | Platform |
|---|---|---|---|
onReceiveClientId |
String |
Called when client ID is received | Android, iOS |
onNotificationMessageArrived |
Map<String, dynamic> |
[Fixed] Called when notification arrives (with full payload) | Android, iOS |
onNotificationMessageClicked |
Map<String, dynamic> |
Called when notification is clicked | Android, iOS |
onReceiveMessageData |
Map<String, dynamic> |
Called when transparent message is received | Android, iOS |
onRegisterDeviceToken |
String |
Called when device token is registered | iOS |
onReceivePayload |
Map<String, dynamic> |
Called when payload is received | iOS |
onReceiveNotificationResponse |
Map<String, dynamic> |
Called when notification response is received | iOS |
onAliasResult |
Map<String, dynamic> |
Called with alias operation result | Android, iOS |
onSetTagResult |
Map<String, dynamic> |
Called with tag operation result | Android, iOS |
๐ Migration from getuiflut #
If you're migrating from the original getuiflut package:
1. Update pubspec.yaml #
dependencies:
# getuiflut: ^0.2.24 # Remove
getui_flutter: ^1.0.0 # Add
2. Update imports #
// Old
import 'package:getuiflut/getuiflut.dart';
Getuiflut plugin = Getuiflut();
// New
import 'package:getui_flutter/getui_flutter.dart';
GetuiFlutter plugin = GetuiFlutter();
3. No other changes needed! #
The API is fully compatible. Your existing code will work without modifications.
๐ Troubleshooting #
Payload is null or empty #
This issue is fixed in this fork! If you're still experiencing issues:
- Make sure you're using
getui_flutter(notgetuiflut) - Check that you've properly configured Getui credentials
- Verify that your push message includes payload data
Client ID is empty #
// Wait for client ID before using it
_getuiPlugin.addEventHandler(
onReceiveClientId: (String clientId) async {
// Use clientId here
await sendClientIdToServer(clientId);
},
// ... other handlers
);
iOS notifications not working #
- Enable push notifications in Xcode capabilities
- Configure APNs certificate in Getui console
- Call
registerRemoteNotification()after SDK initialization
Android notifications not showing #
- Check notification permissions (Android 13+)
- Verify Getui credentials in AndroidManifest.xml
- Ensure Getui SDK dependency is added
๐ Example #
Check the example directory for a complete working example.
๐ Credits #
This plugin is based on getuiflut by ๆนไธ้ซ.
Key Enhancements in This Fork #
- โ
Fixed payload data loss in
onNotificationMessageArrived - โ Enhanced notification data handling
- โ Improved error handling
- โ Better documentation and examples
๐ License #
MIT License
Copyright (c) 2023 ๆนไธ้ซ (Original Author)
Copyright (c) 2025 jjjjjjava (Modifications and Enhancements)
See LICENSE for details.
๐ค Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
๐ฎ Support #
- Issues: GitHub Issues
- Getui Official: https://www.getui.com
๐ Changelog #
See CHANGELOG.md for a detailed list of changes.