Skip to content

Content Notification

NITContent is the object for the notification with content, with the following getters and fields:

  • title returns the title
  • content returns the text content, without processing the html
  • image returns a NITImage object containing the source link of the image uploaded on NearIT if any
  • link returns a NITContentLink object with a label and url if any

Basic example

If you want your app to display a NearIT content in a pop-up dialog, use this simple code:

let vc = NITContentViewController(content: content, trackingInfo: trackingInfo)
NITContentViewController *vc = [[NITContentViewController alloc] initWithContent:content trackingInfo:trackingInfo];
[vc show];

where, content is an instance of NearIT SDK NITContent class and trackingInfo is an instance of NITTrackingInfo. The Content detail window will automatically track user tap events on the content CTA Button.

NearIT-UI content dialog

When the user taps on the button, the link will be opened using the integrated SFSafariViewController. For more advanced usage, the callback handler can be customized:

vc.callToActionHandler = { (viewController, url) in
    // ...
vc.callToActionHandler = ^(NITContentViewController *controller, NSURL *url) {
    // ...

Optionally, you can display the content in your UINavigationController:

let vc = NITContentViewController(content: content, trackingInfo: trackingInfo) navigationController!, /*optional*/ title: "My content detail")
NITContentViewController *vc = [[NITContentViewController alloc] initWithContent:content trackingInfo:trackingInfo];
[vc showWithNavigationController:self.navigationController];
// or 
[vc showWithNavigationController:self.navigationController title:@"my content"];

NearIT-UI content dialog

Advanced examples

If you want to enable the tap-outside-to-close functionality, set isEnableTapToClose to true:

vc.isEnableTapToClose = false
vc.isEnableTapToClose = FALSE;

Links in content and URL in link can be opened in Safari web views without leaving the app (if the iOS version supports them):

vc.openLinksInWebView = true
vc.openLinksInWebView = TRUE;

UI Customization

Some aspect of the UI can be customized with these methods:

vc.imagePlaceholder = UIImage(named: "contentPlaceholder")
vc.ctaFont = UIFont.boldSystemFont(ofSize: 13.0)
vc.titleColor =
vc.titleFont = UIFont.systemFont(ofSize: 15.0)
vc.callToActionButton = UIImage(named: "buttonBackground")
vc.imagePlaceholder = [UIImage imageNamed:@"contentPlaceholder"];
vc.ctaFont = [UIFont boldSystemFontOfSize:13.0];
vc.titleColor = [UIColor blackColor];
vc.titleFont = [UIFont systemFontOfSize:15.0];
vc.callToActionButton = [UIImage imageNamed:@"buttonBackground"];