sendPushMessageToAll method
Future<DataResult<NUIPushOSResponse> >
sendPushMessageToAll({
- required String title,
- required String content,
- String? subtitle,
- NUIEnt? data,
- List<
String> ? includedSegments, - List<
String> ? excludedSegments, - String? bigPictureUrl,
- String? channelId,
override
Send push notification to all subscribe users
Implementation
@override
Future<DataResult<NUIPushOSResponse>> sendPushMessageToAll({required String title, required String content, String? subtitle, NUIEnt? data, List<String>? includedSegments, List<String>? excludedSegments, String? bigPictureUrl, String? channelId}) async{
try{
logNUI(_MODULE, "Sending push notification to all");
final notification = NUIPushOSNotification(
appId: _oneSignalAppId,
headings: {"en": title},
subtitle: subtitle != null ? {"en": subtitle} : null,
contents: {"en": content},
data: data?.toMap(),
bigPicture: bigPictureUrl,
huawei_big_picture: bigPictureUrl,
huawei_channel_id: channelId,
android_channel_id: channelId,
includedSegments: includedSegments ?? [],
excludedSegments: excludedSegments ?? [],
);
final result = await NUIWeb.get(module: _NUIWEB_ONESIGNAL).doPOST<NUIPushOSResponse>(bodyEnt: notification, headers: _oneSignalPushHeaders(), entity: NUIPushOSResponseEntity(), url: '');
if(result.success == true){
logNUI(_MODULE, "Send push message to all successful");
return DataResult(
success: true,
message: "Send push message to all successful",
code: NUIPushCode.PUSH_TO_ALL_SUCCESS.name
);
}
else{
logNUI(_MODULE, "Failed to send push message to all with message: ${result.message}");
return DataResult(
success: false,
message: "Failed to send push message to all with message : ${result.message}",
code: NUIPushCode.PUSH_TO_ALL_FAILED.name
);
}
}catch(e){
logNUI(_MODULE, "Failed to send push message to all with error : $e");
return DataResult(
success: false,
message: "Failed to send push message to all with error: $e",
code: NUIPushCode.PUSH_TO_ALL_FAILED.name
);
}
}