iOS Question CFUUID as safe userID/device

Discussion in 'iOS Questions' started by Alexander Stolte, Apr 15, 2018.

  1. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Hello,

    I'm looking for a way to create a unique id that can serve as userid, it should survive deinstallations without changing.

    why i need it?
    with this id i can identify my users, with this id the user have a anonymous account, with his post, likes etc.

    I googled a bit and found this.

    Now my question is, how can i do that in B4I?

    Greetings
     
  2. tufanv

    tufanv Expert Licensed User

    you can use keychain . it will survive the uninstalls.

    first check if userid key exists with every launch:
    Code:
    p.keychainget("userid")
    if it returns empty it means user is first time launching the app. So assign an id to this device
    Code:
    p.keychainput("userid",Rnd(1000000,9999999))
    At next launches , user id will return the random id generated above even if the user uninstall the app:

    Code:
    p.keychainget("userid")
    an all in one example can be :

    Code:
    dim userid as string
    userid = p.KeyChainGet(
    "userid")
      
            
    If userid="" Then
                userid=
    Rnd(1000000,9999999)
                p.KeyChainPut(
    "userid",userid)
            
    Else
            
    End If
      
        
    Log("user id : " &userid)
     
    rboeck and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice