flutter_smart_ptt 1.0.9
flutter_smart_ptt: ^1.0.9 copied to clipboard
smart-ptt
A intercom library that includes functions such as logging in, logging out, entering groups, exiting groups, making temporary calls, monitoring groups, canceling monitoring groups, sending and receiving messages, etc
Android #
Add the following rules to your proguard-rules.pro file:
-keep class com.corget.** { *; }
-dontwarn java.awt.**
Create object #
FlutterSmartPtt _flutterSmartPttPlugin = FlutterSmartPtt();
Set language #
_flutterSmartPttPlugin.setLanguage("en");
Supported parameters:en、es、fa、fr、it、ja、ko、pt、ru、tr、uk、zh
Monitor data updates for intercom #
PocChangeNotifier pocChangeNotifier = _flutterSmartPttPlugin.getPocChangeNotifier();
pocChangeNotifier.addListener(() {
...
pocChangeNotifier.xxx
...
});
| Field Definition | Comment |
|---|---|
int id |
id |
String account |
Account |
String password |
Password |
String name |
Name |
int status |
Status |
int privilege |
Privilege |
List<dynamic> groups |
List of all groups |
Map groupsMap |
Map of all groups |
Map usersMap |
All users (if a user is in multiple groups, the user object from the last group will be saved) |
int activeGroupId |
Current group ID, 0 indicates not in any group |
bool isRecording |
Whether recording is in progress |
bool isPlaying |
Whether playing is in progress |
String speakingName |
Name of the current speaker |
List<int> speakingIdList |
List of IDs of the current speakers |
bool hideTalker |
Hide the speaker |
int offlineCode |
Offline code, -1: normal exit |
bool isOnline |
Whether online |
String activeGroupName |
Name of the current group |
dynamic showGroup |
Group showing the current members |
int showGroupId |
ID of the group showing the current members |
List<int> monitoredGroupIds |
List of monitored group IDs |
int gpsInterval |
GPS interval |
String location |
Location |
Monitor data updates for settings #
SettingChangeNotifier settingChangeNotifier = _flutterSmartPttPlugin.getSettingChangeNotifier();
settingChangeNotifier.addListener(() {
...
settingChangeNotifier.xxx
...
});
| Field Definition | Comment |
|---|---|
bool enable8KCoding |
Enable 8K coding |
bool enablePTT |
Enable PTT |
bool enableToast |
Whether to enable toast notifications |
bool enableVoiceBroadCast |
Whether to enable voice broadcast |
bool enableBeep |
Whether to enable beep sounds |
bool enableLog |
Whether to enable logging |
Set server address #
_flutterSmartPttPlugin.setUrl(url);
Server Address List: https://corget.com/flutter/url.txt
Login #
_flutterSmartPttPlugin.login(account, password);
Logout #
_flutterSmartPttPlugin.logout();
Start speaking #
_flutterSmartPttPlugin.startPTT();
End speaking #
_flutterSmartPttPlugin.endPTT();
Enter a group based on the group ID #
_flutterSmartPttPlugin.enterGroup(groupId);
Enter the previous group #
_flutterSmartPttPlugin.enterPreGroup();
Enter the next group #
_flutterSmartPttPlugin.enterNextGroup();
Exit the current group #
_flutterSmartPttPlugin.leaveGroup();
Monitor a group based on its ID #
_flutterSmartPttPlugin.addMonitorGroup(groupId);
Cancel monitor a group based on its ID #
_flutterSmartPttPlugin.removeMonitorGroup(groupId);
Send an SOS alert message to the current group. If not currently in the group, send it to the first group #
_flutterSmartPttPlugin.sos();
Temporary call to one or more users #
_flutterSmartPttPlugin.inviteTmpGroup(userIdList);
Pull one or more users into the current group #
_flutterSmartPttPlugin.pullUsersToGroup(userIdList);
Remove one or more users from the current group #
_flutterSmartPttPlugin.disJoinUser(userIdList);
Remove one or more users from the current group #
_flutterSmartPttPlugin.pullUsersToGroup(userIdList);
Make one or more users unable to log in #
_flutterSmartPttPlugin.forceUserExit(userIdList);
Send a message to a group based on the group ID #
_flutterSmartPttPlugin.sendGroupMsg(...);
Send a message to a user based on their ID #
_flutterSmartPttPlugin.sendUserMsg(...);
Modify Setting #
_flutterSmartPttPlugin.enablePTT(true);
_flutterSmartPttPlugin.enablePTT(false);
_flutterSmartPttPlugin.enable8KCoding(false);
_flutterSmartPttPlugin.enable8KCoding(true);
_flutterSmartPttPlugin.enableToast(true);
_flutterSmartPttPlugin.enableToast(false);
_flutterSmartPttPlugin.enableVoiceBroadCast(true);
_flutterSmartPttPlugin.enableVoiceBroadCast(false);
_flutterSmartPttPlugin.enableBeep(true);
_flutterSmartPttPlugin.enableBeep(false);
_flutterSmartPttPlugin.enableLog(true);
_flutterSmartPttPlugin.enableLog(false);
Set callback method #
_flutterSmartPttPlugin.smartPttMethodCall(handleMethodCall);
You can handle callback methods according to your needs
For example, when you receive a text message sent by someone else, you will receive a callback method named "NotifyMsg"
Customize translation content #
Key value pairs for translation:https://corget.com/flutter/intl_en.arb.txt If you want to overwrite the translation,Return custom translation content to the specified translation key, such as:
dynamic handleMethodCall (MethodCall methodCall) {
String method = methodCall.method;
dynamic arguments = methodCall.arguments;
switch (method) {
case "GetTranslation":
String key=methodCall.arguments;
if(key=="Speaking"){
return "is currently speaking,release to end.";
}
break;
}
}
TTS #
Implement TTS playback yourself: Listen to the PlayText method, play the text, and return true
dynamic handleMethodCall (MethodCall methodCall) {
switch (method) {
case "PlayText":
//text:Text to play
String text=methodCall.arguments[0];
//interrupt:Whether to interrupt the previous playback
bool interrupt=methodCall.arguments[1];
logger.i("method callback:PlayText:text: $text");
logger.i("method callback:PlayText:interrupt: $interrupt");
return true;
}
}
Location #
####*IOS On iOS you'll need to add the following entry to your Info.plist file (located under ios/Runner) in order to access the device's location. Simply open your Info.plist file and add the following (make sure you update the description so it is meaningful in the context of your App):
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
More details here:https://pub.dev/packages/geolocator