Skip to content

[issue]: android 12+ some users like relame , oppo not able to subscribe in onesignal they count in subscription record only not count in sunscriber  #959

@Techsol45

Description

@Techsol45

What happened?

5.1.22

below android 12+ its work perfectly but above android 12+ its not able to subscribe user.

image

Steps to reproduce?

please help to fix it:

What did you expect to happen?

please give solution:

OneSignal Flutter SDK version

5.1.22

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

here is my code:


// OneSignal Initialization
Future<void> initPlatformState() async {
  OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
  OneSignal.Debug.setAlertLevel(OSLogLevel.none);

  // Replace with your OneSignal App ID
  OneSignal.initialize("xxxxxxxxxxxxxxxxxxxxxxxxxx");

  // Android 13+ permission handling
  if (io.Platform.isAndroid && io.Platform.operatingSystemVersion.contains('13')) {
    bool? status = await OneSignal.Notifications.requestPermission(true);
    print("Notification permission granted: $status");
  }

  // Additional OneSignal configurations
  OneSignal.LiveActivities.setupDefault();
  OneSignal.Notifications.clearAll();

  bool? allowed = await OneSignal.Notifications.requestPermission(true);
  print('Notifications allowed: $allowed');

  // Observe push subscription
  OneSignal.User.pushSubscription.addObserver((state) {
    print(OneSignal.User.pushSubscription.optedIn);
    print(OneSignal.User.pushSubscription.id);
    print(OneSignal.User.pushSubscription.token);
    print(state.current.jsonRepresentation());
  });

  // Handle notification click
  OneSignal.Notifications.addClickListener((event) {
    print('Notification Clicked: ${event.notification.jsonRepresentation()}');
  });

  // Handle foreground notifications
  OneSignal.Notifications.addForegroundWillDisplayListener((event) {
    event.preventDefault(); // Prevent the default notification display
    event.notification.display(); // Display manually
    print('Foreground Notification: ${event.notification.jsonRepresentation()}');
  });

  // In-app messages click listener
  OneSignal.InAppMessages.addClickListener((event) {
    print('In-App Message Clicked: ${event.result.jsonRepresentation()}');
  });
}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions