App behaves differently when 'opened from within Testflight

If I install and then click 'open' from Testflight - the app cannot get the userid stored in the iCloud 'ubiquitous' keystore - so it sets up a new id for the user - WRONG

If i use testflight to install the app.. but then close testflight and open the app directly by clicking on it - then the app gets the userid from the iCloud keystore and uses that CORRECT

Any ideas why this would be happening?
It also works correctly if I run in debug mode on xcode

Thanks

App behaves differently when 'opened from within Testflight
 
 
Q