intercom icon indicating copy to clipboard operation
intercom copied to clipboard

Type 'Intercom' has no member XXX

Open brennanbatalla opened this issue 2 years ago • 22 comments

Describe the bug After upgrading this plugin to 5.0.0 my ios package fails to build.

Shows three errors:

  • Type 'Intercom' has no member 'presentMessenger'
  • Type 'Intercom' has no member 'presentCarousel'
  • Type 'Intercom' has no member 'presentHelpCenter'
  • Type 'Intercom' has no member 'presentArticle'

Expected behavior The package builds correctly

Screenshots Screenshot 2023-10-04 at 12 56 54 PM

brennanbatalla avatar Oct 04 '23 18:10 brennanbatalla

I'm having the exact same issue! Any progress ?

GavrilF avatar Oct 04 '23 20:10 GavrilF

Not yet, trying everything in the book. If you find a solution, please post it here. I will do the same.

Update: Tried downgrading back and I cannot get rid of this issue now, even in the older versions 🤯

brennanbatalla avatar Oct 05 '23 20:10 brennanbatalla

The Intercom SDK was changed , you need for the moment change the controller swift

nseb avatar Oct 07 '23 12:10 nseb

The Intercom SDK was changed, you need for the moment change the controller swift

@nseb How and where should the controller swift be changed?

stwalez avatar Oct 09 '23 10:10 stwalez

Downgrading Intercom dependency seems to be a good hack. You'd have to modify node_modules...CapacitorCommunityIntercom.podspec for this.

s.dependency 'Intercom', '<= 15.2.3'

Hopefully a better solution is presented.

stwalez avatar Oct 09 '23 13:10 stwalez

Here my code :

Import Foundation import Capacitor import Intercom

/**

  • Please read the Capacitor iOS Plugin Development Guide
  • here: https://capacitorjs.com/docs/plugins/ios */ @objc(IntercomPlugin) public class IntercomPlugin: CAPPlugin { public override func load() { let apiKey = getConfig().getString("iosApiKey") ?? "ADD_IN_CAPACITOR_CONFIG_JSON" let appId = getConfig().getString("iosAppId") ?? "ADD_IN_CAPACITOR_CONFIG_JSON" Intercom.setApiKey(apiKey, forAppId: appId)

#if DEBUG Intercom.enableLogging() #endif

    NotificationCenter.default.addObserver(self, selector: #selector(self.didRegisterWithToken(notification:)), name: Notification.Name.capacitorDidRegisterForRemoteNotifications, object: nil)
}


@objc func didRegisterWithToken(notification: NSNotification) {
    guard let deviceToken = notification.object as? Data else {
        return
    }
    Intercom.setDeviceToken(deviceToken)
}

@objc func loadWithKeys(_ call: CAPPluginCall) {
    let appId = call.getString("appId")  as? String ?? "NO_APP_ID_PASSED"
    let apiKey = call.getString("apiKeyIOS") as? String ?? "NO_API_KEY_PASSED"
    
    Intercom.setApiKey(apiKey, forAppId: appId)
    
    NotificationCenter.default.addObserver(self, selector: #selector(self.didRegisterWithToken(notification:)), name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: nil)
}

@objc func registerIdentifiedUser(_ call: CAPPluginCall) {
    let userId = call.getString("userId")
    let email = call.getString("email")
    let attributes = ICMUserAttributes()
    
    if ((email) != nil) {
        attributes.email = email
        Intercom.loginUser(with: attributes) { result in
            switch result {
            case .success: call.resolve()
            case .failure(let error): call.reject("Error logging in: \(error.localizedDescription)")
            }
        }
    }
    
    if ((userId) != nil) {
        attributes.userId = userId
        Intercom.loginUser(with: attributes) { result in
            switch result {
            case .success: call.resolve()
            case .failure(let error): call.reject("Error logging in: \(error.localizedDescription)")
            }
        }
    }
}

@objc func registerUnidentifiedUser(_ call: CAPPluginCall) {
    Intercom.loginUnidentifiedUser()
    call.resolve()
}

@objc func updateUser(_ call: CAPPluginCall) {
    let userAttributes = ICMUserAttributes()
    let userId = call.getString("userId")
    if (userId != nil) {
        userAttributes.userId = userId
    }
    let email = call.getString("email")
    if (email != nil) {
        userAttributes.email = email
    }
    let name = call.getString("name")
    if (name != nil) {
        userAttributes.name = name
    }
    let phone = call.getString("phone")
    if (phone != nil) {
        userAttributes.phone = phone
    }
    let languageOverride = call.getString("languageOverride")
    if (languageOverride != nil) {
        userAttributes.languageOverride = languageOverride
    }
    let customAttributes = call.getObject("customAttributes")
    userAttributes.customAttributes = customAttributes
    Intercom.updateUser(with: userAttributes)
    call.resolve()
}

@objc func logout(_ call: CAPPluginCall) {
    Intercom.logout()
    call.resolve()
}

@objc func logEvent(_ call: CAPPluginCall) {
    let eventName = call.getString("name")
    let metaData = call.getObject("data")
    
    if (eventName != nil && metaData != nil) {
        Intercom.logEvent(withName: eventName!, metaData: metaData!)
        
    }else if (eventName != nil) {
        Intercom.logEvent(withName: eventName!)
    }
    
    call.resolve()
}

@objc func displayMessenger(_ call: CAPPluginCall) {
    Intercom.present();
    call.resolve()
}

@objc func displayMessageComposer(_ call: CAPPluginCall) {
    guard let initialMessage = call.getString("message") else {
        call.reject("Enter an initial message")
        return
    }
    Intercom.presentMessageComposer(initialMessage);
    call.resolve()
}

@objc func displayHelpCenter(_ call: CAPPluginCall) {
    Intercom.present(.helpCenter)
    call.resolve()
}

@objc func hideMessenger(_ call: CAPPluginCall) {
    Intercom.hide()
    call.resolve()
}

@objc func displayLauncher(_ call: CAPPluginCall) {
    Intercom.setLauncherVisible(true)
    call.resolve()
}

@objc func hideLauncher(_ call: CAPPluginCall) {
    Intercom.setLauncherVisible(false)
    call.resolve()
}

@objc func displayInAppMessages(_ call: CAPPluginCall) {
    Intercom.setInAppMessagesVisible(true)
    call.resolve()
}

@objc func hideInAppMessages(_ call: CAPPluginCall) {
    Intercom.setInAppMessagesVisible(false)
    call.resolve()
}

@objc func displayCarousel(_ call: CAPPluginCall) {
    if let carouselId = call.getString("carouselId") {
        Intercom.presentContent(.carousel(id:carouselId))
        call.resolve()
    }else{
        call.reject("carouselId not provided to displayCarousel.")
    }
}

@objc func setUserHash(_ call: CAPPluginCall) {
    let hmac = call.getString("hmac")
    
    if (hmac != nil) {
        Intercom.setUserHash(hmac!)
        call.resolve()
        print("hmac sent to intercom")
    }else{
        call.reject("No hmac found. Read intercom docs and generate it.")
    }
}

@objc func setBottomPadding(_ call: CAPPluginCall) {
    
    if let value = call.getString("value"),
       let number = NumberFormatter().number(from: value) {
        
        Intercom.setBottomPadding(CGFloat(truncating: number))
        call.resolve()
        print("set bottom padding")
    } else {
        call.reject("Enter a value for padding bottom")
    }
}

@objc func displayArticle(_ call: CAPPluginCall) {
    if let articleId = call.getString("articleId") {
        Intercom.presentContent(.article(id:articleId))
        call.resolve()
    } else {
        call.reject("articleId not provided to presentArticle.")
    }
}

}

nseb avatar Oct 09 '23 15:10 nseb

Same issue when building via Ionic Appflow, any updates?

maylorsan avatar Oct 10 '23 07:10 maylorsan

@maylorsan my code above work this code with the latest Intercom sdk IOS

nseb avatar Oct 10 '23 07:10 nseb

Hello @nseb,

Thank you for sharing your solution! However, directly modifying the source files of installed libraries isn't a viable long-term solution for our use case due to our continuous deployment setup with Ionic Appflow.

Can you contribute your solution directly to this plugin?

maylorsan avatar Oct 10 '23 08:10 maylorsan

Observations:

  • We're using the macOS - 2023.06 build stack in Ionic Appflow, which utilizes Xcode v14.3.1. (in this case build always fails)

  • When building locally with Xcode 15, there are no issues - everything builds successfully!

  • The changelog for Intercom v16.0.0 explicitly notes that Xcode 15 is a requirement for usage. Here’s the exact excerpt from the release notes:

    NOTE: Xcode 15 required for use. In order to work with this version of Intercom, you will need to be using Xcode 15.

Hypothesis:

It seems plausible that the error in question occurs when building with a version of Xcode that is older than 15. Could this be the root cause of the build failure issues we're observing?

maylorsan avatar Oct 10 '23 08:10 maylorsan

I'm on Xcode 15, encountering the same issue. It appears to be contingent on the pod version. When I updated to 1.13.0, I ran into this problem.

ArtBoguslavskiy avatar Oct 10 '23 10:10 ArtBoguslavskiy

@ArtBoguslavskiy I and my team have pod 1.13.0 locally, and everything works well, but with pod 1.12.1 in Ionic Appflow, the build fails.

maylorsan avatar Oct 10 '23 10:10 maylorsan

For your information , I use XCode 15

nseb avatar Oct 10 '23 12:10 nseb

I'm using Ionic in conjunction with the Capacitor plugin @capacitor-community/intercom v5.0.0. Initially, after I reinstalled the plugin, the build process was successful. However, on the second build attempt, it crashed.

Upon inspecting the PodFile, I noticed that the Intercom version specified was 16.0.3. When I downgraded it to version 15.2.3, as suggested by @stwalez, the build succeeded. However, I observed that in Xcode, many of the methods appeared to be deprecated. This appears to be a potential issue, and I suspect that the problem may be related to the usage of new methods introduced in version 16 of Intercom.

ArtBoguslavskiy avatar Oct 10 '23 16:10 ArtBoguslavskiy

Please update "Podfile" under ios/App/Podfile

target 'App' do
  capacitor_pods
  
  #Downgrade intercom due to issues with latest version
  pod 'Intercom', '<= 15.2.3'
  # Add your Pods here
end

this should help to avoid "hardcoding"

juandl avatar Oct 10 '23 21:10 juandl

@juandl works for me!Thank you ❤️

maylorsan avatar Oct 11 '23 07:10 maylorsan

@juandl you are Awesome !!!! where do i send the check !!!!

hopefully a new version of this component will be released to lock down the version or support the latests. this actually causes historical code and builds to break .. even though no code changes were made. not good.

choffmeyer avatar Oct 12 '23 23:10 choffmeyer

Solution worked for me! Thanks! It was a major blocker.

brennanbatalla avatar Oct 19 '23 15:10 brennanbatalla

Anyone using AppFlow and now their buid is failing after fixing the above issue:

image

brennanbatalla avatar Oct 24 '23 20:10 brennanbatalla

@brennanbatalla I resolved the issue by ensuring the pod actually got updated given for me it was stuck with the wrong version in the existing Podfile.lock:

cd ios/App
rm Podfile.lock
pod install

Do gem install cocoapods if you don't have it globally.

supermario avatar Nov 13 '23 14:11 supermario

In the latest build (version: 16.5.8) this presenter has been renamed to Intercom.present()

jbird84 avatar Feb 27 '24 15:02 jbird84

Any update on this? Intercom is not working on IOS Screenshot 2024-04-22 at 6 22 25 PM

nitinw631 avatar Apr 22 '24 22:04 nitinw631