EDITED : On Android it already works (Thanks guys for answering my question!) Now the next question is : How can I retrieve the contact key that is automatically generated from MC when we call enablePush ?
EDITED : On Android it already works (Thanks guys for answering my question!) Now the next question is : How can I retrieve the contact key that is automatically generated from MC when we call enablePush ?
var $j = jQuery.noConflict();
var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;
$j('#link_fetch_device_contacts').click(function() {
logToConsole("link_fetch_device_contacts clicked");
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true;
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);
console.log("MCCordovaPlug : ",);
console.log(MCCordovaPlugin);
document.addEventListener("deviceready",function(){
console.log("deviceready");
MCCordovaPlugin.isPushEnabled(function(success){
console.log("is Push Enabled Success");
console.log(success);
}, function(error){
console.log("is Push Enabled Error");
console.log(error);
});
});
Log:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=console.log(nullerror);
ai_flags=4; ai_family=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null });
netid=1175; mark=1175
02-28 14:25:50.526 391-7656/? D/libc-netbsd: getaddrinfo( app_uid:0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.527 391-7656/? D/libc-netbsd: getaddrinfo: ap5.salesforce.com get result from proxy gai_error = 11
02-28 14:25:50.527 391-7656/? D/libc-netbsd: default dns: query_ipv6=0 }, query_ipv4=1false);
02-28
14:25:50.527 391-7656/? D/libc-netbsd: res_queryN name = ap5.salesforce.com, class = 1, type = 1 });
02
Log:
03-2801 1412:2510:5110.097949 75782174-75782174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(3738)] "TIMING com.salesforce.oauth:getAuthCredentials"jslog: 13.132080078125ms"link_fetch_device_contacts clicked", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.execlogger.js (3738)
0203-2801 1412:2510:5110.098958 75782174-75782174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(28015)] "useProxy:"MCCordovaPlug false":", source: file:///android_asset/www/forceinline.js (28015)
0203-2801 1412:2510:5110.099960 75782174-75782174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(7216)] "Auth"[object succeeded"Object]", source: file:///android_asset/www/indexinline.htmljs (7216)
0203-2801 1412:2610:3710.025960 75782174-75782174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(3819)] "jslog: link_fetch_device_contacts clicked""deviceready", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.loggerinline.js (3819)
0203-2801 1412:2610:3710.035960 75782174-75782682/com.sfapp.contactexplorer IV/chromium~#MCSdkCordovaPlugin: [INFOEXECUTING ACTION:CONSOLE(15)] "MCCordovaPlugisPushEnabled
03-01 12:10:10.965 ",2174-2682/com.sfapp.contactexplorer sourceV/handleIsPushEnabled: fileorg.apache.cordova.CallbackContext@4b990d2
03-01 12:///android_asset/www10:10.971 2174-2682/inlinecom.jssfapp.contactexplorer (15)V/tryHandleIsPushEnabled: org.apache.cordova.CallbackContext@4b990d2
0203-2801 1412:2610:3711.245148 75782174-75782174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: onSuccessDevice: received 119 contacts", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
The function should be called after consoleEdited : I have try to put Log.log "MCCordovaPlug"v in MCCordovaPlugin.java , but seems it stucked in this function :
private boolean handleIsPushEnabled(final CallbackContext callbackContext) {
Log.v("handleIsPushEnabled",callbackContext.toString());
try {
Log.v("tryHandleIsPushEnabled",callbackContext.toString());
MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
@Override
public void ready(MarketingCloudSdk marketingCloudSdk) {
Log.v("handleIsPushEnabledSuccess",callbackContext.getCallbackId());
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, marketingCloudSdk.getPushMessageManager().isPushEnabled()));
}
});
} catch (Exception e) {
Log.v("handleIsPushEnabledError",e);
return caughtException(callbackContext, e);
}
return true;
}
There is no "handleIsPushEnabledSuccess" or "handleIsPushEnabledError" printed on logcat; directly return true.
var $j = jQuery.noConflict();
var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;
$j('#link_fetch_device_contacts').click(function() {
logToConsole("link_fetch_device_contacts clicked");
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true;
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);
console.log("MCCordovaPlug : ", MCCordovaPlugin);
MCCordovaPlugin.isPushEnabled(function(success){
console.log("is Push Enabled Success");
console.log(success);
}, function(error){
console.log("is Push Enabled Error");
console.log(error);
});
});
Log:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=1175; mark=1175
02-28 14:25:50.526 391-7656/? D/libc-netbsd: getaddrinfo( app_uid:0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.527 391-7656/? D/libc-netbsd: getaddrinfo: ap5.salesforce.com get result from proxy gai_error = 11
02-28 14:25:50.527 391-7656/? D/libc-netbsd: default dns: query_ipv6=0, query_ipv4=1
02-28 14:25:50.527 391-7656/? D/libc-netbsd: res_queryN name = ap5.salesforce.com, class = 1, type = 1
02-28 14:25:51.097 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(37)] "TIMING com.salesforce.oauth:getAuthCredentials: 13.132080078125ms", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js (37)
02-28 14:25:51.098 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(280)] "useProxy: false", source: file:///android_asset/www/force.js (280)
02-28 14:25:51.099 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(72)] "Auth succeeded", source: file:///android_asset/www/index.html (72)
02-28 14:26:37.025 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: link_fetch_device_contacts clicked", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
02-28 14:26:37.035 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(15)] "MCCordovaPlug : ", source: file:///android_asset/www/inline.js (15)
02-28 14:26:37.245 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: onSuccessDevice: received 119 contacts", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
The function should be called after console.log "MCCordovaPlug".
var $j = jQuery.noConflict();
var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;
$j('#link_fetch_device_contacts').click(function() {
logToConsole("link_fetch_device_contacts clicked");
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true;
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);
console.log("MCCordovaPlug :");
console.log(MCCordovaPlugin);
document.addEventListener("deviceready",function(){
console.log("deviceready");
MCCordovaPlugin.isPushEnabled(function(success){
console.log("is Push Enabled Success");
console.log(success);
}, function(error){
console.log("is Push Enabled Error");
console.log(error);
});
}, false);
});
Log:
03-01 12:10:10.949 2174-2174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: link_fetch_device_contacts clicked", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
03-01 12:10:10.958 2174-2174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(15)] "MCCordovaPlug :", source: file:///android_asset/www/inline.js (15)
03-01 12:10:10.960 2174-2174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(16)] "[object Object]", source: file:///android_asset/www/inline.js (16)
03-01 12:10:10.960 2174-2174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(19)] "deviceready", source: file:///android_asset/www/inline.js (19)
03-01 12:10:10.960 2174-2682/com.sfapp.contactexplorer V/~#MCSdkCordovaPlugin: EXECUTING ACTION: isPushEnabled
03-01 12:10:10.965 2174-2682/com.sfapp.contactexplorer V/handleIsPushEnabled: org.apache.cordova.CallbackContext@4b990d2
03-01 12:10:10.971 2174-2682/com.sfapp.contactexplorer V/tryHandleIsPushEnabled: org.apache.cordova.CallbackContext@4b990d2
03-01 12:10:11.148 2174-2174/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: onSuccessDevice: received 119 contacts", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
Edited : I have try to put Log.v in MCCordovaPlugin.java , but seems it stucked in this function :
private boolean handleIsPushEnabled(final CallbackContext callbackContext) {
Log.v("handleIsPushEnabled",callbackContext.toString());
try {
Log.v("tryHandleIsPushEnabled",callbackContext.toString());
MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
@Override
public void ready(MarketingCloudSdk marketingCloudSdk) {
Log.v("handleIsPushEnabledSuccess",callbackContext.getCallbackId());
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, marketingCloudSdk.getPushMessageManager().isPushEnabled()));
}
});
} catch (Exception e) {
Log.v("handleIsPushEnabledError",e);
return caughtException(callbackContext, e);
}
return true;
}
There is no "handleIsPushEnabledSuccess" or "handleIsPushEnabledError" printed on logcat; directly return true.
MC Cordova Plugin version : 1.0.2
Snippet Code :
var $j = jQuery.noConflict();
var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;
$j('#link_fetch_device_contacts').click(function() {
logToConsole("link_fetch_device_contacts clicked");
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true;
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);
console.log("MCCordovaPlug : ", MCCordovaPlugin);
MCCordovaPlugin.isPushEnabled(function(success){
console.log("is Push Enabled Success");
console.log(success);
}, function(error){
console.log("is Push Enabled Error");
console.log(error);
});
});
Log:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=1175; mark=1175
02-28 14:25:50.526 391-7656/? D/libc-netbsd: getaddrinfo( app_uid:0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.527 391-7656/? D/libc-netbsd: getaddrinfo: ap5.salesforce.com get result from proxy gai_error = 11
02-28 14:25:50.527 391-7656/? D/libc-netbsd: default dns: query_ipv6=0, query_ipv4=1
02-28 14:25:50.527 391-7656/? D/libc-netbsd: res_queryN name = ap5.salesforce.com, class = 1, type = 1
02-28 14:25:51.097 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(37)] "TIMING com.salesforce.oauth:getAuthCredentials: 13.132080078125ms", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js (37)
02-28 14:25:51.098 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(280)] "useProxy: false", source: file:///android_asset/www/force.js (280)
02-28 14:25:51.099 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(72)] "Auth succeeded", source: file:///android_asset/www/index.html (72)
02-28 14:26:37.025 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: link_fetch_device_contacts clicked", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
02-28 14:26:37.035 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(15)] "MCCordovaPlug : ", source: file:///android_asset/www/inline.js (15)
02-28 14:26:37.245 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: onSuccessDevice: received 119 contacts", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
The function should be called after console.log "MCCordovaPlug".
Please help about this issue.. Thanks!
Please help about this issue.. Thanks!
MC Cordova Plugin version : 1.0.2
Snippet Code :
var $j = jQuery.noConflict();
var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;
$j('#link_fetch_device_contacts').click(function() {
logToConsole("link_fetch_device_contacts clicked");
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true;
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);
console.log("MCCordovaPlug : ", MCCordovaPlugin);
MCCordovaPlugin.isPushEnabled(function(success){
console.log("is Push Enabled Success");
console.log(success);
}, function(error){
console.log("is Push Enabled Error");
console.log(error);
});
});
Log:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.524 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=0; mark=0
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo( app_uid:10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() uid prop:
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: getaddrinfo() getuid():10622
02-28 14:25:50.525 7578-7655/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk hostname=ap5.salesforce.com; servname=(null); netid=1175; mark=1175
02-28 14:25:50.526 391-7656/? D/libc-netbsd: getaddrinfo( app_uid:0
02-28 14:25:50.526 391-7656/? D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
02-28 14:25:50.527 391-7656/? D/libc-netbsd: getaddrinfo: ap5.salesforce.com get result from proxy gai_error = 11
02-28 14:25:50.527 391-7656/? D/libc-netbsd: default dns: query_ipv6=0, query_ipv4=1
02-28 14:25:50.527 391-7656/? D/libc-netbsd: res_queryN name = ap5.salesforce.com, class = 1, type = 1
02-28 14:25:51.097 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(37)] "TIMING com.salesforce.oauth:getAuthCredentials: 13.132080078125ms", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js (37)
02-28 14:25:51.098 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(280)] "useProxy: false", source: file:///android_asset/www/force.js (280)
02-28 14:25:51.099 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(72)] "Auth succeeded", source: file:///android_asset/www/index.html (72)
02-28 14:26:37.025 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: link_fetch_device_contacts clicked", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
02-28 14:26:37.035 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(15)] "MCCordovaPlug : ", source: file:///android_asset/www/inline.js (15)
02-28 14:26:37.245 7578-7578/com.sfapp.contactexplorer I/chromium: [INFO:CONSOLE(38)] "jslog: onSuccessDevice: received 119 contacts", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.logger.js (38)
The function should be called after console.log "MCCordovaPlug".
Please help about this issue.. Thanks!