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
625 stars 214 forks source link

[question]: set external id #892

Closed RodrigoRodriguez1 closed 6 months ago

RodrigoRodriguez1 commented 6 months ago

How can we help?

I need to insert an external id in the username

class NewCustomWidget extends StatefulWidget { const NewCustomWidget({ super.key, this.width, this.height, this.onPressed, });

final double? width; final double? height; final Function()? onPressed;

@override State createState() => _NewCustomWidgetState(); }

class _NewCustomWidgetState extends State { @override Widget build(BuildContext context) { // Define container decoration (optional) final BoxDecoration decoration = BoxDecoration( color: FlutterFlowTheme.of(context).primaryColor, borderRadius: BorderRadius.circular(10.0), ); return GestureDetector( onTap: widget.onPressed ?? () => showDialog( context: context, builder: (context) => AlertDialog( title: Text('Alert'), content: Text('teste'), actions: [ TextButton( onPressed: () { OneSignal.Notifications.requestPermission(true); OneSignal.LiveActivities.setupDefault();

                      var id = OneSignal.User.pushSubscription.id;
                      // it would be here
                      OneSignal.User.setExternalUserId(externalUserId);
                      OneSignal.User.addAlias(
                          OneSignal.User.pushSubscription.id.toString(),
                          "1341524");
                      Navigator.pop(context);

                    },
                    child: Text('OK'),
                  ),
                ],
              ),
            ),
    child: Container(
      width: widget.width,
      height: widget.height,
      decoration: decoration, 
      child: Container(),
    ));

} }

Code of Conduct

temcewen commented 6 months ago

Use the "login" function instead.