Skip to content
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

Type 'Intercom' has no member XXX #96

Open
brennanbatalla opened this issue Oct 4, 2023 · 22 comments
Open

Type 'Intercom' has no member XXX #96

brennanbatalla opened this issue Oct 4, 2023 · 22 comments

Comments

@brennanbatalla
Copy link

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

@GavrilF
Copy link

GavrilF commented Oct 4, 2023

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

@brennanbatalla
Copy link
Author

brennanbatalla commented Oct 5, 2023

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 🤯

@nseb
Copy link

nseb commented Oct 7, 2023

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

@stwalez
Copy link

stwalez commented Oct 9, 2023

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
Copy link

stwalez commented Oct 9, 2023

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.

@nseb
Copy link

nseb commented Oct 9, 2023

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.")
    }
}

}

@maylorsan
Copy link

maylorsan commented Oct 10, 2023

Same issue when building via Ionic Appflow, any updates?

@nseb
Copy link

nseb commented Oct 10, 2023

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

@maylorsan
Copy link

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
Copy link

maylorsan commented Oct 10, 2023

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?

@ArtBoguslavskiy
Copy link

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.

@maylorsan
Copy link

@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.

@nseb
Copy link

nseb commented Oct 10, 2023

For your information , I use XCode 15

@ArtBoguslavskiy
Copy link

ArtBoguslavskiy commented Oct 10, 2023

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.

@juandl
Copy link

juandl commented Oct 10, 2023

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"

@maylorsan
Copy link

@juandl works for me!Thank you ❤️

@choffmeyer
Copy link

@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.

@brennanbatalla
Copy link
Author

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

@brennanbatalla
Copy link
Author

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

image

@supermario
Copy link

@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.

@jbird84
Copy link

jbird84 commented Feb 27, 2024

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

@nitinw631
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.