Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to Receive Push Notification on Android #992

Open
2 of 3 tasks
hwasiq15 opened this issue Jan 27, 2025 · 1 comment
Open
2 of 3 tasks

[Bug]: Unable to Receive Push Notification on Android #992

hwasiq15 opened this issue Jan 27, 2025 · 1 comment

Comments

@hwasiq15
Copy link

hwasiq15 commented Jan 27, 2025

What happened?

I have set up the OneSignal dashboard and configured Firebase, but the app neither receives push notifications nor prompts for notification permission. I’ve double-checked the setup, but it still doesn’t seem to work. Any suggestions on what might be missing or causing this issue?

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize Firebase
  await Firebase.initializeApp();
  configureOneSignal();

  runApp(const MyApp());
}

// Configure OneSignal SDK
void configureOneSignal() {
  // Enable verbose logging for development
  OneSignal.Debug.setLogLevel(OSLogLevel.verbose);

  // Initialize OneSignal with the app ID
  OneSignal.initialize("b38128ff-0561-499c-ab67-87fb6c3b9911");

  // Request notification permissions
  OneSignal.Notifications.requestPermission(true).then((granted) {
    if (granted) {
      debugPrint("Notification permission granted.");
    } else {
      debugPrint("Notification permission denied.");
    }
  });
}

Steps to reproduce?

Set up the OneSignal dashboard and completed the configuration.
Integrated Firebase into the app and ensured the connection with OneSignal.
Installed the app on a test device and launched it.
Noticed the following issues:
The app does not ask for notification permissions when launched.
Push notifications are not received on the device.

What did you expect to happen?

I expected the app to prompt the user for notification permissions upon launching for the first time. After granting permission, I expected the app to successfully receive and display push notifications sent via the OneSignal dashboard.

OneSignal Flutter SDK version

5.2.9

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

D/OneSignal(25249): [main] initWithContext: SDK already initialized
D/OneSignal(25249): [main] Retrieving service interface com.onesignal.inAppMessages.IInAppMessagesManager
D/OneSignal(25249): [main] Already instantiated: com.onesignal.inAppMessages.internal.InAppMessagesManager@46e2990
D/OneSignal(25249): [main] InAppMessagesManager.addLifecycleListener(listener: com.onesignal.flutter.OneSignalInAppMessages@8f1c289)
D/OneSignal(25249): [main] Retrieving service interface com.onesignal.inAppMessages.IInAppMessagesManager
D/OneSignal(25249): [main] Already instantiated: com.onesignal.inAppMessages.internal.InAppMessagesManager@46e2990
D/OneSignal(25249): [main] InAppMessagesManager.addClickListener(listener: com.onesignal.flutter.OneSignalInAppMessages@8f1c289)


9): [DefaultDispatcher-worker-3] HttpClient: Request Sent = POST https://api.onesignal.com/apps/b38128ff-0561-499c-ab67-87fb6c3b9911/users - Body: {"subscriptions":[{"type":"AndroidPush","token":"","enabled":false,"notification_types":-8,"sdk":"050126","device_model":"Infinix X663","device_os":"12","rooted":false,"net_type":0,"carrier":"Telenor","app_version":"1"}],"properties":{"timezone_id":"Asia\/Karachi","language":"en"},"refresh_device_metadata":true} - Headers: Accept=[application/vnd.onesignal.v1+json], Content-Type=[application/json; charset=UTF-8], OneSignal-Install-Id=[d4366c9b-2751-4570-afd7-ba562b007452], OneSignal-Subscription-Id=[local-2521de17-08a7-4341-8627-4c0ec7a45b75], SDK-Version=[onesignal/android/050126], SDK-Wrapper=[onesignal/flutter/050209]

 Operation execution failed, retrying: [{"name":"login-user","appId":"b38128ff-0561-499c-ab67-87fb6c3b9911","onesignalId":"local-ab4481c7-0b59-4664-ad28-42c06b6f3779","id":"ea84622b-befa-4b57-889e-dfbfbb72859a"}, {"name":"create-subscription","appId":"b38128ff-0561-499c-ab67-87fb6c3b9979","onesignalId":"local-ab4481c7-0b59-4664-ad28-42c06b6f3779","subscriptionId":"local-2521de17-08a7-4341-8627-4c0ec7a45b75","type":"PUSH","enabled":false,"address":"","status":"NO_PERMISSION","id":"4847d83a-8cc6-429d-a97c-25e883892091"}, {"name":"update-subscription","appId":"b38128ff-0561-499c-ab67-87fb6c3b9979","onesignalId":"local-ab4481c7-0b59-4664-ad28-42c06b6f3779","subscriptionId":"local-2521de17-08a7-4341-8627-4c0ec7a45b75","type":"PUSH","enabled":false,"address":"","status":"FIREBASE_FCM_INIT_ERROR","id":"ed5446de-0ea0-4071-a84b-007aa1d965ad"}]

I/OneSignal(25249): [Thread-10] Failed to get Android parameters, trying again in 90 seconds.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shahdab22
Copy link

facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants