registerForPushNotifications

Registers the device for push notifications without a callback.

This is a convenience method that calls registerForPushNotifications with a null callback. Use this method when you don't need to handle registration results. Example:


  // Simple registration without callback
  Pushwoosh.getInstance().registerForPushNotifications();

See also


Registers the device for push notifications with a callback.

This method initiates the registration process with FCM/GCM and registers the device with Pushwoosh. The callback provides information about the registration result including the push token and notification permission status. Example:


  // Register for push notifications in Application onCreate or MainActivity
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      // Register for push notifications (permission requested automatically on Android 13+)
      Pushwoosh.getInstance().registerForPushNotifications((result) -> {
          if (result.isSuccess()) {
              String pushToken = result.getData().getToken();
              boolean notificationsEnabled = result.getData().isEnabled();
              Log.d("App", "Push registration successful. Token: " + pushToken);

              // Optionally store registration status
              SharedPreferences prefs = getSharedPreferences("app_prefs", MODE_PRIVATE);
              prefs.edit().putBoolean("push_registered", true).apply();
          } else {
              Exception exception = result.getException();
              Log.e("App", "Push registration failed: " + exception.getMessage());
              // Show user-friendly error message
              Toast.makeText(this, "Unable to enable notifications", Toast.LENGTH_SHORT).show();
          }
      });
  }

Parameters

callback

push registration callback