-
Notifications
You must be signed in to change notification settings - Fork 0
APNS Setup
GravitumLabs edited this page Nov 3, 2016
·
8 revisions
Analytics Init method automaticaly registering with Apple Push Notification service(APNs), if you will turn them on with method useNotifications:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
Analytics * analytics = [[Analytics getAnalytics] initWithParameters:AppToken
AppSecret:AppSecret
SenderId:SenderId];
/////////////////////////////////////////////////////////////////////////////////
// Optional
[analytics SetUserId: userID];
[analytics SetUserName: userName;
[analytics SetGender: (Gender*)userGender];
[analytics SetBirthday: userBirthDay
monthBorn: userBirthMonth
yearBorn: userBirthYear
];
// Optional end
/////////////////////////////////////////////////////////////////////////////////
// Turn ON push notifications
[analytics useAnalytics : YES]; //or [[Analytics getAnalytics] useNotifications : YES];
/////////////////////////////////////////////////////////////////////////////////
[analytics Init]; //Launch analytics;
return YES;
}The next step will be send received from APNs yourDeviceToken. Also for analytics - listen for remote notifications. To implement this two steps copy code below and paste it to the AppDelegate.m script
-(void)application : (UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(nonnull NSData *)deviceToken{
// NSLog(@"Registered! With Data: %@", deviceToken);
[[Analytics getAnalytics] SetDevicePushTokenData:deviceToken];
}
-(void)application : (UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo{
//Recieved notification
if(application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground){
//Notification was clicked from background or inactive state
[[Analytics getAnalytics] OpenedFromPush:userInfo];
}
}Result should be like at a screenshot:
Check if BundleIdentifier valid (with provisioning profile)
Check code singing identity to automatic (developer or distribution)
Turn On Push Notifications in Capabilities



