NotifyVisitors

Integration

Intialize and import NotifyVisitors SDK.

Import the NotifyVisitors SDK in your project

Download the sdk zip file from below which has some files library (.a file), header file (.h file), plist file (.plist file) and some images (.png file), from the sdk download link and include them into your project. Simply drag and include them in your project.

1. Configure your info.plist

Open info.plist of your project as source code (right click on info.plist and click on Open as >> Source code) and add the following code in it.

📘

Note:

In below example Dummy Brand ID and Secret keys shown. Kindly login to your account to see your credentials.

<key>NSAppTransportSecurity</key>
    <dict>
       <key>NSAllowsArbitraryLoads</key>
       <true/>
    </dict>

<key>CFBundleURLTypes</key>
     <array>
           <dict>
                <key>CFBundleURLName</key>
                <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
                <key>CFBundleURLSchemes</key>
                <array>
                        <string>YOUR_URL_SCHEME</string>
                </array>
           </dict>
     </array>

<key>nvBrandID</key>
<integer>YOUR_BRANDID_COMES_HERE</integer>

<key>nvSecretKey</key>
<string>YOUR_SECRET_KEY_COMES_HERE</string>

<key>nvPushCategory</key>
<string>nvpush</string>

<key>nvViewAutoRedirection</key>
<true/>    <!--OR--> <!-- <false/>-->

If you are using our older iOS SDK upto version 5.3.3 or below then add the following into your info.plist file if you are using our latest iOS SDK(version 6.0.1 or above) then skip this step.

<key>NSUserTrackingUsageDescription</key>
          <string>This identifier will be used to deliver personalized ads to you</string>

OR

You can simply open the info.plist and add the keys which works as same as above for this.

1.1 Add a new row by going to the menu and clicking Editor > Add Item. Setup a NSAppTransportSecurity as a Dictionary.

1.2 Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

1.3 Add a new row again and set up a URL Types item by adding a new item. Expand the URL Types key, expand Item 0, and add a new item, URL schemes. Fill in “appScheme” for Item 0 of URL schemes and your company identifier for the URL Identifier. Your file should resemble the image below when done.

1.4 Add a new row again and set up a nvBrandID as Number and fill this field with your BRANDID

1.5 Add a new row again and set up a nvSecretKey as String and fill this field with your SECRET KEY

{8A991DED60F2186660EF8A337C30BDDE}

1.6 Add a new row again and set up a nvPushCategory as String and set it’s value nvpush.

1.7 Add a new row again and set up a key nvViewAutoRedirection as Boolean set it YES to enable auto redirection of your app’s ViewControllers from sdk or set it NO to handle redirections by your app.

1.8 If you are using Notifyvisitors iOS SDK version 5.3.3 or below then follow the step (a) given below if you are using our latest version iOS SDK (version 6.0.1 or above) then we have removed using IDFA from our SDK so you don’t need to follow the below step just skip this step.

  • Notifyvisitors iOS SDK (upto version 5.3.3. Or below) is using IDFA so as per Apple’s new guideline after iOS14 release to display the App Tracking Transparency authorization request for accessing the IDFA, add a new row again and set up a key NSUserTrackingUsageDescription key with a custom message describing your usage. Here is an example description text: “This identifier will be used to deliver personalized ads to you.

📘

Note

If you are updating our iOS SDK from any older version (v~5.3.3 or below) sdk to our latest version of SDK (v~6.0.1 or above version) and if your info.plist is still having key NSUserTrackingUsageDescription then check if your app or any other third party library in your app is not using IDFA then REMOVE this key from your App’s info.plist.

1.9 Goto Signing & Capabilities Tab and if “Background Modes” is not already added then click on the + symbol on the left corner of this tab and add Background Modes make sure to select 2 checkboxes. If it is already added then make sure to select 2 checkboxes (i.e. Background fetch, Remote notifications).

In the Signing & Capabilities Tab and click on + symbol on the left corner of this tab and add Push Notifications and if you are upgraded Xcode and Push Notifications was already added in previous version of Xcode then remove Push Notifications and add it again to configure push notification properly for the upgraded devices.

In the Signing & Capabilities Tab if “App Groups” is not already added then click on + symbol on the left corner of this tab and add App Groups and click on + sign and add a new app group give the group name as group.nv.{Your App Bundle Identifier}.

Example : if Your App’s Bundle Identifier is com.example.myapp then the App Group must be named as group.nv.com.example.myapp make sure this newly created app group must be checked (Turned on)

Import header file

Objective-C
Include the header file in`.m` file in which sdk function is to be accessed.

#import "notifyvisitors.h"

Swift
Add a new header file and name it with the following format. YOUR_PROJECT_NAME-Bridging-Header.h Example if your project name is test. Then the header file name will be test-Bridging-Header.h. Now add the following import statement in YOUR_PROJECT_NAME-Bridging-Header.h for accessing Native SDK Classes.

#import "notifyvisitors.h"

Make sure that the path of bridge-header.h file is included in build settings under “Swift compiler-code generation” as:
Objective C bridging header: YOUR_PROJECT_NAME/YOUR_PROJECT_NAME-Bridging-Header.h

Initialize the sdk in application didFinishLaunchingWithOptions function.

  • nvMode: Define a NSString nvMode and set its value “debug” or “live” based on preprocessor if condition so that sdk knows the app is running in debugging mode or downloaded from AppStore (i.e. live mode) as follows.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
var nvMode:String? = nil
        #if DEBUG
        nvMode = "debug"
        #else
            nvMode = "live"
        #endif
        notifyvisitors.initialize(nvMode)
  return true
}
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
 NSString *nvMode = nil;
#if DEBUG
    nvMode = @"debug";
#else
     nvMode = @"live";
#endif
    [notifyvisitors Initialize:nvMode];
  return YES
}
  • Add the following method in applicationDidEnterBackground in your AppDelegate file.
notifyvisitors.applicationDidEnterBackground(application)
[notifyvisitors applicationDidEnterBackground: application];
  • Add the following method in application applicationDidBecomeActive in your AppDelegate file.
notifyvisitors.applicationDidBecomeActive(application)
[notifyvisitors applicationDidBecomeActive: application];
  • Add the following method in applicationWillEnterForeground in your AppDelegate file.
notifyvisitors.applicationWillEnterForeground(application)
[notifyvisitors applicationWillEnterForeground];
  • Add the following method in applicationWillTerminate in your AppDelegate file.
notifyvisitors.applicationWillTerminate()
[notifyvisitors applicationWillTerminate];
  • Geo-fencing: To handle the geofencing notifications add the following Code to receive notification when geofencing events trigger.
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *) notification {
[notifyvisitors NotifyVisitorsGeofencingReceivedNotificationWithApplication:application window:self.window didReceiveGeofencingNotification:notification];                         
}
  • Deep Linking: Use the following method in your AppDelegate OpenURL method that will check the deep linking and open your app from URL Scheme.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
notifyvisitors.openUrl(with: app, url: url)
return true           
   }
-(BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
        [notifyvisitors OpenUrlWithApplication:application Url:url];
        return YES;  
}

Updated 4 months ago


What's Next

Tracking Events

Integration


Intialize and import NotifyVisitors SDK.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.