2

The Salesforce Mobile SDK has a cordova plugin. The Capacitor platform supports most but not all Cordova plugins (see known incompatability list). Does anyone know if the Salesforce mobile sdk cordova app works with Capacitor?

5 Answers 5

2

Capacitor is not a platform we officially support, but I do know that customers are using it and we have not heard about any large blocking issues. Our upkeep of Cordova is minimal at this point but we do not have any plans to adopt Capacitor at this time.

1
  • Ok, thanks. So you are saying customers are using the Salesforce MobileSDK Cordova plugin with Cordova and you've not heard of blocking issues? Or, you are saying that customers are using the Salesforce MobileSDK Cordova plugin with Capacitor and you've not heard of blocking issues? Also, since the Cordova upkeep is minimal, is the longer-term focus of the Salesforce Mobile SDK team React Native then?
    – Rozgonyi
    May 22, 2020 at 18:44
1

UPDATE: after forking the plugin and making changes I have everything built and compiling. The app is registering in MC yet no client info is received nor do push notifications arrive in ios or in android. So my answer still stands: No it is not compatible out of the box.

I have been at it for over 2 days straight and I can not get my capacitor android app to compile with the MC-Cordova-Plugin. I have had to battle a lot of issues to get to a point where nothing seems to fix the latest error:

Parsing json file: xxxxx/android/capacitor-cordova-android-plugins/google-services.json

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:processDebugGoogleServices'.
> No matching client found for package name ''

While the package name in google-services.json is certainly not an empty string.

So unless you hear otherwise on here I would assume it is not compatible. At the very least not out of the box

2
  • Did you ever make further progress with this? Is your forked version of the plugin public? Looking to start the same process so anything you could share would be awesome.
    – Phil B
    Aug 2, 2021 at 17:26
  • Yes I did get it to work in the end. My fork is at github.com/pzontrop/MC-Cordova-Plugin . It has been months so I don't remember exactly all the steps I had to take to make it work in the end but feel free to create an issue on the github fork if you need extra help. I will try to answer asap.
    – pascalzon
    Aug 4, 2021 at 8:10
1

Using Capacitor 3.0.0-beta, it's work well with Android and I received the push notification with success.

But at iOS it's not working yet and I'm testing and debugging to understand what the problem is.

Has anyone successfully managed notifications with capacitor 3.0 on iOS?

1
  • On iOS, apparently, the opt-in is failing and the device does not register correctly. Feb 11, 2021 at 21:42
1

I'm using capacitor 2, I implemented the SDK (MC-Cordova-Plugin) and on android it worked perfectly in the case of IOS I needed to include these lines of code in the AppDelegate:

import MarketingCloudSDK

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {


    // MobilePush SDK: REQUIRED IMPLEMENTATION
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        MarketingCloudSDK.sharedInstance().sfmc_setDeviceToken(deviceToken)
    }

    // MobilePush SDK: REQUIRED IMPLEMENTATION
    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        print(error)
    }

    // MobilePush SDK: REQUIRED IMPLEMENTATION
    /** This delegate method offers an opportunity for applications with the "remote-notification" background mode to fetch appropriate new data in response to an incoming remote notification. You should call the fetchCompletionHandler as soon as you're finished performing that operation, so the system can accurately estimate its power and data cost.
     This method will be invoked even if the application was launched or resumed because of the remote notification. The respective delegate methods will be invoked first. Note that this behavior is in contrast to application:didReceiveRemoteNotification:, which is not called in those cases, and which will not be invoked if this method is implemented. **/
    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        MarketingCloudSDK.sharedInstance().sfmc_setNotificationUserInfo(userInfo)
        completionHandler(.newData)
    }
0

We tried to use the SDK using the Capacitor, but it did not work properly. The notification is not received by the SDK, apparently the Capacitor receives it.

As the capacitor has a native push notification mechanism at its core, I suppose that the solution must pass through the receipt of the notification by the capacitor, which should call the MC SDK.

Thus, we are unable to use the features provided by the SDK. Probably, the best solution would be a rewritten plugin for Capacitor.

I suggested creating a new Capacitor plugin on the "Capacitor Community" forum on Github. If you want to vote on this suggestion, the link is this:

https://github.com/capacitor-community/proposals/issues/73

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .