Giter VIP home page Giter VIP logo

collectapushsdk's Introduction

MEDRICS Healthcare Solutions Corp

Collecta Push SDK

Version Platform

Requirements

Installation

Using CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Our SDK into your Xcode project using CocoaPods, specify it in your Podfile:

target 'your_project_name' do
  pod 'CollectaPushSDK'
end

Then install the pods using pod install --repo-update

Usage

Initialize CollectaPushSDK in your app

You can add CollectaPushSDK initialization code to your application either at startup ,or at the desired point in your application flow. Import the CollectaPushSDK module and configure a shared instance as shown:

  1. Import the CollectaPushSDK module in your UIApplicationDelegate:

    import CollectaPushSDK
  2. Configure a CollectaPushSDK shared instance, typically in your app's messaging(_:didReceiveRegistrationToken:) method to be notified whenever the firebase token is updated:

    CollectaPushSDK.shared.initialize(username:"your-user-name",
                                      password: "your-password",
                                      source:"source-1",
                                      uuid:"user-id",
                                      fcmToken:fcmToken)

    Parameters:

    • username -> username we provide
    • password -> password we provide
    • source -> source we provide
    • uuid -> unique id for the user
    • fcmToken -> Firebase registration token
  3. To respond to the delivery of notifications, you must implement a delegate for the shared UNUserNotificationCenterobject in application(_:didFinishLaunchingWithOptions:):

    UNUserNotificationCenter.current().delegate = self
  4. Your delegate object must conform to the UNUserNotificationCenterDelegate protocol ,and implement the userNotificationCenter(_:didReceive:withCompletionHandler:) and userNotificationCenter(_:willPresent:withCompletionHandler:) methods.

     func userNotificationCenter(_ center: UNUserNotificationCenter, 
                                 didReceive response: UNNotificationResponse, 
                                 withCompletionHandler completionHandler: @escaping () -> Void) {
         let userInfo = response.notification.request.content.userInfo
         CollectaPushSDK.shared.didReceiveMessage(userInfo:userInfo)
         completionHandler()
     }
     
     func userNotificationCenter(_ center: UNUserNotificationCenter, 
                                 willPresent notification: UNNotification, 
                                 withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions)->Void) {
        completionHandler([.alert,.sound,.badge])
     }

Add Notification Service Extension

We want to modify the payload of a remote notification before it's displayed on the user’s iOS device so we use UNNotificationServiceExtension.

  1. In Xcode Select File > New > Target...
  2. Select Notification Service Extension then press Next.
  3. Enter the product name as MyNotificationServiceExtension and press Finish.
  4. Press Cancel on the Activate scheme prompt. By cancelling, you are keeping Xcode debugging your app, instead of just the extension. If you activate by accident, you can always switch back to debug your app within Xcode (next to the play button).
  5. In the project navigator, select the top level project directory and select the MyNotificationServiceExtension target in the project and targets list. Unless you have a specific reason not to, you should set the Deployment Target to be iOS 10.
  6. Open NotificationService.swift and add our didReceiveNotificationExtensionRequest method to didReceive(_ request:withContentHandler:) method as shown below
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
         self.contentHandler = contentHandler
         bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
         
         CollectaPushSDK.shared.didReceiveNotificationExtensionRequest(request, withContentHandler:contentHandler)
     }
  7. Add the CollectaPushSDK dependency under your project name target as well as MyNotificationServiceExtension target like below
    target 'your_project_name' do
    pod 'CollectaPushSDK'
    end
    
    target 'MyNotificationServiceExtension' do
    pod 'CollectaPushSDK'
    end

Then install the pods using pod install --repo-update

Credits

Collecta SDK is owned and maintained by the MEDRICS Healthcare Solutions Corp. You can follow us on Linkedin at MEDRICS for project updates and releases.

Copyright

Copyright © 2020 MEDRICS Healthcare Solutions Corp. All rights reserved.

collectapushsdk's People

Contributors

emre-medrics avatar

Stargazers

Muhammad Alkhalaf avatar

Watchers

Muhammad Alkhalaf 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.