I have an android app created with Unity, I can send notifications to this app from OneSignal web site and from my php website successfully. Now I want to send notifications from a flutter app (android). I tried the onesignal sdk for flutter example but it sends the notification to the flutter app and not to Unity app. I don't know where am I wrong :

    Future<void> initPlatformState() async {
    if (!mounted) return;

    var settings = {
      OSiOSSettings.autoPrompt: false,
      OSiOSSettings.promptBeforeOpeningPushUrl: true

    // NOTE: Replace with your own app ID from https://www.onesignal.com
    await OneSignal.shared
        .init("9a98990f-40fa-455e-adda-ccd474594f41", iOSSettings: settings);


    bool requiresConsent = await OneSignal.shared.requiresUserPrivacyConsent();

    this.setState(() {
      _enableConsentButton = requiresConsent;

  void _handleSendNotification() async {
    var status = await OneSignal.shared.getPermissionSubscriptionState();

    var playerId = status.subscriptionStatus.userId;

    var imgUrlString =

    var notification = OSCreateNotification(
        playerIds: [playerId],
        content: "this is a test from OneSignal's Flutter SDK",
        heading: "Test Notification",
        iosAttachments: {"id1": imgUrlString},
        bigPicture: imgUrlString,
        buttons: [
          OSActionButton(text: "test1", id: "id1"),
          OSActionButton(text: "test2", id: "id2")

    var response = await OneSignal.shared.postNotification(notification);

    this.setState(() {
      _debugLabelString = "Sent notification with response: $response";

Solution 1: Rodrigo Gomez-Palacio

It sounds like you're looking for P2P (user-user) notifications. You will need a way to get the player id of the target app (Unity) from the Flutter app.