-
Notifications
You must be signed in to change notification settings - Fork 232
Description
What happened?
I’m using the latest OneSignal Flutter SDK (onesignal_flutter 5.3.3 this what i am trying with) in a Flutter project. I’ve configured everything correctly:
Location permissions declared in AndroidManifest.xml
Location permission requested at runtime using permission_handler
OneSignal.Location.requestPermission() and setShared(true) are called
SDK initialized properly and tags are sent successfully
✅ It works perfectly in debug mode
❌ But fails to send location in release mode only
Even in a clean Flutter test project with correct configuration, location never shows up in the OneSignal Dashboard in release builds.
However, when I manually send location using User.addTags, it works in all modes.
Please advise if this is a known issue or if there is a workaround.
Steps to reproduce?
1- Create a new Flutter project:
flutter create onesignal_location_test
2- Add the following dependencies to pubspec.yaml:
onesignal_flutter:
permission_handler:
3- In android/app/src/main/AndroidManifest.xml, add:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
4- In lib/main.dart, add the following code:
import 'package:flutter/material.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
initOneSignal();
}
Future<void> initOneSignal() async {
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.initialize('YOUR_ONESIGNAL_APP_ID'); // Replace with actual OneSignal App ID
OneSignal.Notifications.requestPermission(true);
var status = await Permission.location.request();
if (status.isGranted) {
await Future.delayed(const Duration(seconds: 2)); // Ensure SDK is ready
OneSignal.Location.requestPermission();
OneSignal.Location.setShared(true);
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(child: Text('OneSignal Location Test')),
),
);
}
}
- Build the app in release mode:
flutter build apk --release
adb install -r build/app/outputs/flutter-apk/app-release.apk
- Launch the app on a real Android device (not an emulator), and grant location permission when prompted.
- Check the OneSignal Dashboard → Audience → All Users → inspect the user entry.
What did you expect to happen?
User location should appear automatically in the user properties.
OneSignal Flutter SDK version
5.3.3
Which platform(s) are affected?
- iOS
- Android
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct