Skip to content

[Question]: User 'Never Subscribed' #1833

@farzd

Description

@farzd

We were previously using Expo push notifications, to port over our users to One Signal ?
They will not see a push notification native prompt since they already got one from Expo - so is this enough? (looking to get User 'subscribed')

// init / login 
  useNotificationPermissions(userId);

  useEffect(() => {
    if (userId) {
      if (__DEV__) {
        OneSignal.Debug.setLogLevel(LogLevel.Verbose);
      }

      OneSignal.setConsentRequired(true);
      OneSignal.setConsentGiven(true);
      OneSignal.initialize(oneSignalAppId);
      OneSignal.login(userId);
    }
  }, [userId]);



  const handleMigrateNotifications = async () => {
    try {
      // Request permission (might not show dialog if already granted)
      const granted = await OneSignal.Notifications.requestPermission(true);
      console.log("Permission request result:", granted);

      if (granted) {
        // Force OneSignal to opt in and get the ID
        OneSignal.User.pushSubscription.optIn();

        // Get OneSignal ID and manually update database
        const onesignalID = await OneSignal.User.getOnesignalId();
        console.log("OneSignal ID for migration:", onesignalID);

        if (onesignalID) {
          // update DB
          console.log("Migration completed successfully");
        }
      }
    } catch (error) {
      console.error("Error during migration:", error);
    }
  };


Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions