2

so i wanted to create a cordova hybrid app using SalesforceMobileSDK alongside MarketingCloud plugin for push notification. I've added SalesforceMobileSDK cordova plugin and so far it runs perfectly. I also succesfully added MarketingCloud plugin into the project, but i still can't get it to work.

I've done all the setup required on Marketing Cloud side and implemented the code to my app and some function like MCCordovaPlugin.isPushEnabled is working seemingly fine. But everytime i called MCCordovaPlugin.enablePush, it doesn't return anything. Furthermore, everytime i run the app, it display a pop up that says it failed configureSDKwithAppID.

Here is the XCode log:

2018-03-06 17:06:45.971402+0700 Test[22207:348577] initiate MCCordovaPlugin
2018-03-06 17:06:45.971557+0700 Test[22207:348577] MCCordovaPlugin :  [object Object]
2018/03/06 10:06:45.999 Test[22207:7c0b] DEBUG com.salesforce: webView:shouldStartLoadWithRequest:navigationType: Loading URL 'file:///Users/Wowow/Library/Developer/CoreSimulator/Devices/2C443269-FD84-44B4-BCD7-16289631BC62/data/Containers/Bundle/Application/3B830487-9AF7-4EE6-BB86-6118C4A8F96A/Test.app/www/index.html#/landing-page'
2018-03-06 17:06:46.000065+0700 Test[22207:348577] success isPushEnabled at appcomp
2018-03-06 17:06:46.002766+0700 Test[22207:348577] false
2018-03-06 17:06:46.002912+0700 Test[22207:348577] success getSystemToken
2018-03-06 17:06:46.005290+0700 Test[22207:348577] null
2018-03-06 17:06:47.859710+0700 Test[22207:348682] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert
2018-03-06 17:06:47.860121+0700 Test[22207:348682] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert
2018-03-06 17:07:45.976141+0700 Test[22207:348577] foundation version = 1450.000000

Here is the code snippet, the MCCordovaPlugin.isPushEnabled and MCCordovaPlugin.getSystemToken get success message while MCCordovaPlugin.enablePush doesn't appear on Log:

console.log("initiate MCCordovaPlugin");
console.log("MCCordovaPlugin : ",MCCordovaPlugin);

MCCordovaPlugin.enablePush(success => {
    console.log("success enable push get");
    console.log(success);
}, error =>{
    console.log("error enable push get");
    console.log(error);
});

MCCordovaPlugin.isPushEnabled((success)=>{
    console.log("success isPushEnabled at appcomp");
    console.log(success);
}, (error) => {
    console.log("error isPushEnabled at appcomp");
    console.log(error);
});

MCCordovaPlugin.getSystemToken((success)=>{
    console.log("success getSystemToken");
    console.log(success);
}, (error) => {
    console.log("error getSystemToken");
    console.log(error);
});

Here is the Screenshot of popup:

I am using Cordova 7.0.0, Cordova iOS 4.5.4, Java 1.8.0, SalesforceMobileSDk 5.3.0, and MC Cordova Plugin 1.0.2.

I also found another similar question, though it only has answers for Android so far: Marketing Cloud Cordova Plugin Push Notification Issue - iOS and Android

Any idea on how i can get this to work, guys? Thanks.

Regards.

2 Answers 2

0

It looks like the configureSDKwithAppID is being called twice. Are you switching AppIDs? For instance, if you are switching between development and production environments and switching config values, you are probably calling the configureSDKwithAppID twice and will need to delete the app on your device and start over with the new appID.

The configureSDKwithAppID is called by our SDK and should not be called necessarily by the user's app.

6
  • No, we're still using the same AppID from the start. I'm not sure though if i'm calling configureSDKwithAppID twice or not. i haven't made any changes to the MCCordovaPlugin code and the functions that i use on the user app are only MCCordovaPlugin.getSystemToken, MCCordovaPlugin.isPushEnabled, and MCCordovaPlugin.enablePush... I also tried uninstalling and reinstalling the app on the test device. It still display the error popup... Commented Mar 7, 2018 at 3:32
  • If you are doing platform specific development in Cordova can you run your project in xcode and put a breakpoint to see if the configureSDKwithAppID is being called more than once?
    – Tom Brooks
    Commented Mar 7, 2018 at 14:30
  • Hi Tom, thanks for answering. Im not really familiar with XCode development, so im not really sure what you meant.. but i found configureSDKWithAppId on AppDelegate+MCCordovaPlugin, and i tried putting a printf log above it.. And yes it is called twice, but im not sure whats calling it... maybe it's called by the SalesforceSDK plugin, since after the SalesforceSDK is removed the popup doesn't appear anymore... But, we need the SalesforceSDK so we cannot remove it and even after the SalesforceSDK is removed, the MCCordovaPlugin.enablePush is still not called... Commented Mar 8, 2018 at 7:46
  • OK... I do like the idea of uploading a vanilla generic project that could demonstrate this issue. Are you able to do that? Also make sure you do not include any client-specific values in your project such as AppID, AccessToken, etc; I can take a look at what you have and track it down on my side.
    – Tom Brooks
    Commented Mar 8, 2018 at 13:57
  • Yes, i just uploaded the sample project to github.com/dodicendana/MarketingCloudForDebugging.git ... I removed the platforms and the MCCordovaPlugin, so you can use your own Marketing Cloud APPID, access token, etc... Commented Mar 9, 2018 at 4:49
0

One thing you can try is to see if you have plugin conflict 1) Uninstall sdk plugin and install MC Cordova Plugin and see if it works. (I've had few issues with other plugins but around Android not ios).

10
  • Hi Serge, thanks for the answer... I tried your suggestion and yes the error popup doesn't appear anymore.. But the function enablePush still doesn't work, it still doesn't return any value... Commented Mar 7, 2018 at 4:27
  • Do you see a notification about enabling push notifications when you start the application ?? Also you can go step further to simplify things ... create simple Cordova app like helloWorld app and just install the MC plugin and see if that works ... Also did you just uninstall the SDK plugin or have you uninstall both plugins then dropped platform( I found installing plugins before the creation of platform to work the best with Cordova, NOTE do that only if you don't have any custom code in platform folder or you have it under repository) and then installed mc plugin ??
    – Serge Tk
    Commented Mar 7, 2018 at 10:59
  • Yes there is a popup asking for permission to allow push notification for the app... the error popup used to appear after i pressed 'ok' on this permission popup... Ya i tried removing both plugin and the platform, then after that re-installing the MCCordova first and then re-add the platform, it still fail to enablePush.. I also tried to create a new project only adding MCCordova Plugin, still the same result. Commented Mar 7, 2018 at 12:41
  • Cool, then my next question is. Do you have access to SalesForce Cloud Marketing Console to check if a contact has been created?
    – Serge Tk
    Commented Mar 7, 2018 at 20:31
  • 1
    Can you upload the vanilla project on github or another place so I could try and run it on my machine?
    – Serge Tk
    Commented Mar 8, 2018 at 9:09

You must log in to answer this question.

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