Integration with OneSignal Push Notifications

Amor

Member
Hello! I'm trying to add support for OneSignal Push notifications on my XenForo installation. I set up a new route /newdevice that is supposed to accept a POST and store device data to the database in order to associate users to their device. Here's the function in my controller so far:

PHP:
public function actionNewDevice()
{
    $this->_assertPostOnly();
    
    $visitor = XenForo_Visitor::getInstance()->toArray();
    
    $user_id = $visitor['user_id'];
    
    if($user_id) {
        ...
    }
}

The problem I'm having is that the $visitor array returns 0 values. I need to associate the user to the device so I NEED $visitor['user_id'] but the value is 0 so I don't get into if($user_id).

When I do a var_dump on the $visitor array I get this:

PHP:
array(76) {
  ["user_id"]=>
  int(0)
  ["username"]=>
  string(0) ""
  ["email"]=>
  string(0) ""
  ["gender"]=>
  string(0) ""
  ...
}

All zeros! Not like in my other controllers! Can anyone help?
 
Back
Top Bottom