Medo
Medo

Reputation: 35

How can get user info?

How can get the user name is Bixby providing any information about the user like his name?

I tried to add bixby-user-id-access and user-profile-access to use $vivContext to get some information but there is name for user. Also i tried to pass self.GetSelf but the result returned was empty and there is no user information.

computed-input (self) { 
      type (self.Self)
      min (Optional) max (One)
      compute {
        intent {
          goal: self.Self
          route: self.GetSelf
        }
      }
}
property (self) {
    type (self.Self)
    min (Required) max (One)
}

The value of self property

Upvotes: 2

Views: 113

Answers (1)

BixbyDevSupport-Tokonyan
BixbyDevSupport-Tokonyan

Reputation: 1501

$vivContext does not contain such information. Please check here to see what $vivContext contains and how to access it in JS.

It is the correct approach to use viv.self library. To access you need user-profile-access permission. Read more about viv.self library here.

Please follow this example, developer needs setup their profile first on a Samsung phone. For developers not yet have a Samsung phone, one can try to get familiar with the structure by using viv.self.GetImaginarySelf. The name will be "Hi Bixby" when using viv.self.GetImaginarySelf.

You can also download and try the sample capsule provide in this KB article

action (GetAllNames) {
  description (__DESCRIPTION__)
  type (Search)
  collect {
    computed-input (self) {
      type (self.Self)
      min (Optional) max (One)
      compute {
        intent {
          goal: self.Self
          route: self.GetImaginarySelf // for developers has NO Samsung device
          // route: self.GetSelf // for release
        }
      }
    }
  }
  output (TextName)
}

And in linked JS in endpoints file, do this.

module.exports.function = function getAllNames (self) {
  var rslt = []
  rslt.push ("John")
  rslt.push ("Jane")
  if (self == null) {
    rslt.push ("NULL")
  }
  else {
    rslt.push(self.nameInfo.structuredName)
  }
  return rslt;
}

You should be able to see the name in result view. enter image description here

You should also be able to check other field of returned viv.self.Self structure in debugger window. enter image description here

Upvotes: 1

Related Questions