OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
618 stars 212 forks source link

[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

Open Techsol45 opened 1 month ago

Techsol45 commented 1 month ago

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?

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

jennantilla commented 17 hours ago

Hello @Techsol45 thanks for your patience! Is this still an issue for you? If so, please provide the device logsreproducing this behavior and we'll be happy to assist. Thanks!