I'm trying to create a function that delivers a push notification to all app's users that redirect the user to the corresponding aplication's store accordind to the platform (one for iOS and another for Android). Here is my code:
await OneSignal.shared.setAppId('APP-ID');
await OneSignal.shared
.promptUserForPushNotificationPermission()
.then((accepted) {});
OneSignal.shared.setNotificationOpenedHandler((openedResult) {
OSNotificationDisplayType.notification;
});
OneSignal.shared.setNotificationWillShowInForegroundHandler((event) {
OSNotificationDisplayType.notification;
});
}
Future<void> addPosts(
String cdMessage,
String cdCpfCnpj,
) async {
const url = "https://apps.apple.com/br/app/integra-on/id1620788591";
await http.post(Uri.https('onesignal.com', '/api/v1/notifications'),
body: jsonEncode({
"app_id": "APP-ID",
"include_external_user_ids": [cdCpfCnpj],
"data": {"platform": "IOS","foo": "bar"},
"platform": "IOS",
"url": url,
"contents": {"en": cdMessage}
}),
headers: {
"Accept": "application/json",
"content-type": "application/json",
"Authorization":
"Basic KEY"
});
// var data = response.body;
}
i've tried to use 'Platform.isAndroid\Platform.isIOS', but it refers for the app sending the notifications, not the one recieving them. Anyone can help please?