//ThismethodiscalledwhenAPNSregistrationsucceeds.
-(void)application:(UIApplication*)appdidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"APNSregistrationsucceeded!");
//APNSregistrationhassucceededandprovidedtheAPNSdevicetoken.StartregistrationwithPCFPush
//NotificationServiceandpassittheAPNSdevicetoken.
//
//Required:Createafileinyourprojectcalled"Pivotal.plist"inordertoprovideparametersforregisteringwith
//PCFPushNotificationService
//
//Optional:YoucanprovideacustomuserIDtoassociateyourdevicewithitsuser.
//
//Optional:Youcanalsoprovideasetoftagstosubscribeto.
//
//Optional:Youcanalsoprovideadevicealias.Theuseofthisdevicealiasisapplication-specific.
//Werecommendthatyouusetheuser'sdevicenametopopulatethisfield.
//
//Optional:Youcanpassblockstogetcallbacksafterregistrationsucceedsorfails.
//
[PCFPushregisterForPCFPushNotificationsWithDeviceToken:deviceToken
tags:YOUR_TAGS
deviceAlias:YOUR_DEVICE_ALIAS
customUserId:YOUR_CUSTOM_USER_ID
areGeofencesEnabled:ARE_GEOFENCES_ENABLED
success:^{
NSLog(@"CFregistrationsucceeded!");
}failure:^(NSError*error){
NSLog(@"CFregistrationfailed:%@",error);
}];
}
The
YOUR_TAGS
parameterisaparameterthatprovidesasetofthetagsthatyou’dliketheapplicationtosubscribeto.Thisparametershouldbean
NSSet
objectcontainingasetof
NSString
objects.IfyoupassintagsviathisregistermethodthenyouneedtoprovideALLtagsthattheuserhas
subscribedtoeachtimeregistrationiscalled.Tomanageyourtagsyoucanalsocallthe
[PCFPushsubscribeToTags:success:failure:]
method(described
below).
The
YOUR_DEVICE_ALIAS
parameterisacustomparameterthatyoucanusetoidentifyauser’sdevice(eg:ausermayhavemultipledevices)-thisis
forfutureuse.Werecommendthatyouusetheuser’sdevicenametopopulatethisfield(e.g.:
UIDevice.currentDevice.name
).
The
YOUR_CUSTOM_USER_ID
parameterisanothercustomparameterthatyoucanusetoassociatethisdevicewiththeuser.Itispossibletotarget
pushnotificationstocustomuserIDs.Ifyoudon’twanttousethecustomuserIDthenyoucansetthisargumentto
nil
oranemptystring.Custom
userIDsaretreatedascase-sensitive.Formoreinformation,seeRegisteringwithaCustomUserID.
The
ARE_GEOFENCES_ENABLED
isa
BOOL
valuethatturnsthegeofencesfeatureonandoff(describedbelow).
Allofthe
deviceAlias
,
tags
,
success
,and
failure
parametersareoptionalandmaybesetto
nil
.
Youcancallthe
[PCFPushregisterForPCFPushNotificationsWithDeviceToken:tags:deviceAlias:customUserId:areGeofencesEnabled:success:failure:]
methodwheneveryour
parameterizationchangesduringruntime(e.g.:whenyouwanttoupdatethedevicealias).Itisnotharmfultocallthismethodseveraltimesduringthe
lifetimeofaprocess.
RegistrationExamples
Example1:RegisteringforPushNotificationswithnooptions,tags,andwithoutgeofences.
-(void)application:(UIApplication*)appdidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
[PCFPushregisterForPCFPushNotificationsWithDeviceToken:deviceToken
tags:nil
deviceAlias:nil
customUserId:nil
areGeofencesEnabled:NO
success:^{NSLog(@"CFregistrationsucceeded!");}
failure:^(NSError*error){NSLog(@"CFregistrationfailed:%@",error);}];
}
Example2:RegisteringforPushNotificationswithacustomeruserIDusingtheuser’saccountname(forexample).