asynchronous - Synchronization when implementing push , iOS -
i have special problem of synchronization application share , ideas me solve it.
i developing application 2 things :
1) registers push notifications in appdelegate
.
2) opens webview in viewcontroller
, loads url. form of url loaded : http://.www.thisismyurl.com/udid
, udid users unique identifier.
in didregisterforremotenotificationswithdevicetoken:
registering token , after receive , inside function make http request server send push token , udid.
so in both didregisterforremotenotificationswithdevicetoken
of appdelegate
, in viewcontroller
retrieving udid , using described.
everything till last week worked perfectly. apple decided reject application using udid. way go me create unique identifier using cfuuid , save key chain.
the problem :
as see make use of unique identifier both in appdelegate's didregisterforremotenotificationswithdevicetoken
function inside viewcontroller
. must created in 1 of these controllers or else different!!! (remember cfuuid string created udid + datentime).
where should create ??? didregisterforremotenotificationswithdevicetoken
asynchronous if retrieve there , viewcontroller make http request long before unique identifier reaches there , use null
instead. same case happen viewcontroller
. if try create there , maybe didregisterforremotenotificationswithdevicetoken
function called faster , try register in database null
unique identifier .
so can try create cfuuid string , sure controllers on time?
edit
an idea came on top of head. if created cfuuid inside didfinishlaunchingwithoptions
function of appdelegate
?? if not mistaken part of code run first , before else. there wont synchronization problem ll pass safely everywhere need it. right?
as said, didfinishlaunchingwithoptions
first method executed when application launched.
if create cfuuid
@ beginning of method, before registering push notifications, have value when receive device token apple (when didregisterforremotenotificationswithdevicetoken
called), , have value time open webview
.
Comments
Post a Comment