Giter Club home page Giter Club logo

mustache-agillic-ios-sdk's Introduction

Agillic SDK for iOS

The Agillic SDK enables you to utilize the Agillic platform from within your iOS App. The SDK currently includes the following functionality:

  • Register devices used by a recipient in your mobile application.
  • Register a recipient token required to send a Push Notification to a device using Apple PN on iOS or Firebase Cloud Messaging for Android. When registered, this token will allow sending push notifications to recipients via the Agillic Dashboard.
  • Track recipient App Views. Tracking can be paused and resumed when requested by the user. Tracked events can be used to define Target Groups in the Agillic Dashboard which can be used to direct targeted marketing and other communication.

Other useful information:

Requirements

  • Requires minimum iOS 11+

Installation

See the subsections below for details about the different installation methods.

Swift Package Manager (recommended)

Add a package by selecting FileAdd Packages… in Xcode’s menu bar.

Search for the Agillic iOS SDK using the repo's URL:

https://github.com/agillic/agillic-ios-sdk.git

For detailed documentaion on setting up the Agillic SDK with Swift Package Manger see: Swift Package Manager

Import Manually

NOTE: This is not the recommended method.

  • Download this repository by selecting CodeDownload ZIP.
  • Open Downloads and locate ./src/AgillicSDK folder
  • Drag and drop the AgillicSDK to your project
  • Make sure to check Copy items if needed and Add to your App Target.
  • The Agillic SDK are dependant on the Snowplow iOS Tracker SDK version 1.7.1 and FMDB (OUT OF SCOPE)

Initializing the Agillic SDK

In order to use AgillicSDK you have to initialize and configure it first.

You can configure your Agillic instance in code:

  • AGILLIC API KEY
  • AGILLIC API SECRET
  • AGILLIC SOLUTION ID

See how to setup your Agillic Solution and obtain these values in the Agillic Solution Setup Guide.

Initialize in app

Start by importing the AgillicSDK Module into your AppDelegate.swift file

import AgillicSDK

Initialize and configure the Agillic SDK upon launch

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    Agillic.shared.configure(apiKey: "AGILLIC API KEY", apiSecret: "AGILLIC API SECRET", solutionId: "AGILLIC SOLUTION ID")
    return true
}

Your Agillic SDK instance is now ready for usage.

Logging

Optionally you can enable logging for debug usage.

Agillic.shared.logger.logLevel = .verbose

Usage

Register App Installation

Prerequisites

  • You need to make sure to do this AFTER Agillic.shared.configure().
  • You must do this upon every launch before doing any App View Tracking.
  • Register has to be done in your Sign Up/Sign In flow but also on you splash screen if users are automatically logged in with an Access Token.
  • RECIPIENT ID - Has to match RECIPIENT.EMAIL in the Agillic Recipient Table
Register App Installation
Agillic.shared.register(recipientId: "RECIPIENT ID")

Register Push Token

Prerequisites

  • Configure your app to be able to receive Push Notifications Read this toturial

  • Read the Agillic Push Notification Setup document to learn how to send Push Potifications to your iOS application directly from your Agillic Solution.

  • Request permission for Remote Push Notifications in your App and obtain the Push Token from APNS NOTE: This requires you to have already obtained the Recipient ID and that you store this across app sessions - this is currently only supported for unknown recipients.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
        if let error = error {
            print("Error: \(error.localizedDescription)")
        } else {
            DispatchQueue.main.async {
                application.registerForRemoteNotifications()
            }
        }
    }
    return true
}
Register App Installation

Read deviceToken and add it to your Agillic Recipient.

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    
    let pushToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    
    // Register with PushToken
    Agillic.shared.register(recipientId: "RECIPIENT ID", pushNotificationToken: pushToken)
}

Track Push Opened

NOTE: Work in progress

Reading Push Notification sent from your Agillic

NOTE: Work in progress

Handling deeplinking from Agillic

NOTE: Work in progress

App View Tracking

Track recipient behavior with App View Tracking.

App View Tracking is typically located in your UIViewController file, but can be used elsewhere if needed.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let appView = AgillicAppView(screenName: "app://sublevel-1/sublevel-2")
    Agillic.shared.tracker.track(appView)
}

The screenName is the value that can be matched in the Condition Editor. We suggest to use a hierarchical naming convention, prefixed with app:// ex:

  • app://sublevel-1/sublevel-2/...

Examples of usage:

  • app://landingpage
  • app://landingpage/sign-up/step-2
  • app://dashboard
  • app://product-offers
  • app://product-offers/21
  • app://menu/profile/edit

TODO: Usage in combination with 'Deeplinking' and 'Dynamic Links'

Questions and Issues

Please provide any feedback via a GitHub Issue.

Copyright and license

Agillic SDK for iOS is available under the Apache 2.0 license. See LICENSE file for more info.

   Copyright 2021 Agillic

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

mustache-agillic-ios-sdk's People

Contributors

finnhlarsen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.