New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Countly is not accessible #13

Closed
GaneshShetty951 opened this Issue Jul 26, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@GaneshShetty951
Copy link

GaneshShetty951 commented Jul 26, 2018

I have installed Countly through pods when i enabled Notification from Countly Documentation, CountlyNSE folder created and inside NotificationService.swift file created i edited that file as mentioned in Countly documentaion but that giving error No Such Module 'Countly' .

`import UserNotifications
//import Countly

class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
    
    //delete existing template code, and add this line
   //CountlyNotificationService.didReceive(request, withContentHandler: contentHandler);
}

override func serviceExtensionTimeWillExpire() {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
        contentHandler(bestAttemptContent)
    }
}

}`

@GaneshShetty951 GaneshShetty951 changed the title Coutly is not accessible Countly is not accessible Jul 26, 2018

@erkanyildiz

This comment has been minimized.

Copy link
Member

erkanyildiz commented Jul 29, 2018

This is a known CocoaPods issue where you add a subspec for an extension target on a Swift project. CocoaPods/CocoaPods#7733

cocoapodstable

Please disable CocoaPods for Notification Service Extension target (CountlyNSE), and integrate CountlyNotificationService files manually:

  1. Please delete these:
target 'CountlyNSE' do
...
end

from your Podfile, and keep only your main app target.

  1. after you use pod install command, manually add CountlyNotificationService.h and CountlyNotificationService.m files to your Notification Service Extension target (CountlyNSE) from Pods directory.

  2. Create a Swift Bridging Header file for your extension target.
    File name should be CountlyNSE-Bridging-Header.h automatically.
    And you should import CountlyNotificationService.h in it.

#import "CountlyNotificationService.h"
  1. Under your extension target's Build Settings > Objective-C Bridging Header section, specify bridging header file's path.

e.g. CountlyNSE/CountlyNSE-Bridging-Header.h

  1. Now you can call CountlyNotificationService.didReceive(request, withContentHandler: contentHandler) method in your NotificationService.swift file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment