I create an Application to Read and Update Contacts Details. Here is a problem to updating Contact email. (I'm using Ionic 3)
When I try to add information to an existing contact the app closes and the console dont show nothing more. I'm using android studio to see the APK in the mobile and does not allow me to update. Here my code:
Update: I got the follow error:
"Wrong type for parameter "properties" of contacts.create: Expected Object, but got String."
"Error in Success callbackId: Contacts1616016237 : TypeError: Wrong type for parameter "properties" of contacts.create: Expected Object, but got String."
I pass the id as a parameter and I look for the contact to update.
UpdateContact(id, email){
var options = new ContactFindOptions();
options.filter = id;
options.multiple = true;
let proms = [];
this.contacts.find(["id"], options).then(res=>{res.forEach( (item:Contact) => {
//console.log(contact);
proms.push(new Promise( (resolve, reject) => {
var f = new ContactField('email',email,true);
item.emails = [];
item.emails.push(f);
console.log('FIXED '+item.displayName);
item.save().then(() => console.log('Contact saved!'),
(error: any) => console.error('Error saving contact.', error)
);
resolve();
}))
})
})
}
Related
I am able to programmatically log in to the PowerBI Client, gather my Workspaces as well as get a specific Report from a specific Workspace. I need to programmatically render that report to a .pdf or .xlsx file. Allegedly this is possible with the ExportToFileInGroup/ExportToFileInGroupAsync methods. I even created a very simple report without any parameters. I can embed this using the sample app from here. So that at least tells me that I have what I need setup in the backend. But it fails when I try to run the ExportToFileInGroupAsync method (errors below code.)
My Code is:
var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(new string[] {
PowerBiScopes.ReadReport,
PowerBiScopes.ReadDataset,
});
var userInfo = await graphServiceClient.Me.Request().GetAsync();
var userName = userInfo.Mail;
AuthDetails authDetails = new AuthDetails {
UserName = userName,
AccessToken = accessToken,
};
var credentials = new TokenCredentials($"{accessToken}", "Bearer");
PowerBIClient powerBIClient = new PowerBIClient(credentials);
var groups = await powerBIClient.Groups.GetGroupsAsync();
var theGroup = groups.Value
.Where(x => x.Name == "SWIFT Application Development")
.FirstOrDefault();
var groupReports = await powerBIClient.Reports.GetReportsAsync(theGroup.Id);
var theReport = groupReports.Value
.Where(x => x.Name == "No Param Test")
.FirstOrDefault();
var exportRequest = new ExportReportRequest {
Format = FileFormat.PDF,
};
string result = "";
try {
var response = await powerBIClient.Reports.ExportToFileInGroupAsync(theGroup.Id, theReport.Id, exportRequest);
result = response.ReportId.ToString();
} catch (Exception e) {
result = e.Message;
}
return result;
It gets to the line in the try block and then throws the following errors:
An error occurred while sending the request.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
UPDATE
Relating to #AndreyNikolov question, here is our Embedded capacity:
After this was implemented, no change. Same exact error.
Turns out the issue was on our side, more specifically, security/firewall settings. Here is the exact quote from our networking guru.
"After some more investigation we determined that our firewall was causing this issue when it was terminating the SSL connection. We were able to add a bypass for the URL and it is now working as expected."
I am working on the paypal integration to my ionic app,…Happily i could easily implement the paypal with static value, but when I tried to dynamic value it shows an error.
Payment not processable in console.
continueSubscription(){
//initialize payment......
this.payPal.init({
PayPalEnvironmentProduction: '',
PayPalEnvironmentSandbox: 'XXXXXX'
}).then(() => {
var data = this.paymentAmount;
// Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({})).then(() => {
console.log(this.selectedValue);
var payment = new PayPalPayment(this.selectedValue.amount, this.selectedValue.currency_type, 'Description', this.selectedValue.descryption);
this.payPal.renderSinglePaymentUI(payment).then((res) => {
// Successfully paid
this.paymentResponse = res;
}, (error) => {
console.log(error);
// Error or render dialog closed without being successful
});
}, () => {
// Error in configuration
});
}, () => {
// Error in initialization, maybe PayPal isn't supported or something else
});
}
below share the updated ts code and selectedValue is object in which we have pass dynamic data and i pass following object to payment:
amount: "200"
bnCode: "PhoneGap_SP"
currency: "INR"
details: undefined
intent: "Health Record With Conditioncjn dfgh"
shortDescription: "Description"
Please team tell me how to fix above error ?
Did you make sure that this.selectedValue.amount is a string?
PayPal expects the amount as a string, no number / int is accepted.
What does your console say if you execute console.log(this.selectedValue.amount);?
You could also try to use single quotes instead of double quotes.
I'm trying to figure out the "correct" way to set up push notifications on an Ionic v3 app using the OneSignal SDK and native plugin (iOS is all I care about, for the moment). My goal is to set up an observer using the addSubscriptionObserver hook provided by the plugin, and update my database with the userId when the user opts in to notifications. I believe the problem I'm having has to do with the scope the callback is running in. I am trying to access the userService (injected into the component where the subscriptionObserver is added), but I am getting the following error when the callback runs:
2018-04-22 09:59:53.977213-0700 WodaX[2610:692168] Error in Success callbackId: OneSignalPush492317370 : TypeError: undefined is not an object (evaluating 'this.userService.updateUserOneSignalId')
Here is my code:
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.statusBar.overlaysWebView(false);
this.keyboard.disableScroll(false);
this.splashScreen.hide();
// OneSignal Code start:
// Enable to debug issues:
//window["plugins"].OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
let notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
let iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = false;
window["plugins"].OneSignal
.startInit("[MY_ONE_SIGNAL_APP_ID]")
.handleNotificationOpened(notificationOpenedCallback)
.inFocusDisplaying(window["plugins"].OneSignal.OSInFocusDisplayOption.Notification)
.iOSSettings(iosSettings)
.endInit();
window["plugins"].OneSignal.addPermissionObserver(this.handlePermissionChange);
window["plugins"].OneSignal.addSubscriptionObserver(this.handleSubscriptionChange);
});
}
openPage(page) {
this.nav.setRoot(page.component);
}
private handleSubscriptionChange(data: any) {
console.log(data)
if (data.to.userSubscriptionSetting && data.to.userId) {
let userUuid = "testId"
this.userService.updateUserOneSignalId(userUuid, data.to.userId).subscribe((res) => {
console.log(res);
}, (err) => {
console.log(err);
});
}
}
The same call to the userService method works in a the getIds callback in a different component, so I'm guessing this has something to do with how the callbacks are registered by the addSubscriptionObserver method.
Here is the operative plugin code:
OneSignal.prototype.addSubscriptionObserver = function(callback) {
OneSignal._subscriptionObserverList.push(callback);
var subscriptionCallBackProcessor = function(state) {
OneSignal._processFunctionList(OneSignal._subscriptionObserverList, state);
};
cordova.exec(subscriptionCallBackProcessor, function(){}, "OneSignalPush", "addSubscriptionObserver", []);
}
I'd appreciate insight from anyone who may have successfully set this up. The goal is to be able to store individual OneSignal Ids so users can trigger notifications to other users. I can do this now, but only if I do it when the user accepts the prompt. I need to be able to do it anytime they opt in to push notifications, even from the settings after declining the original prompt.
So you have faced pretty common pitfall handling 'this' during a call of a function with a callback method.
Normally if you see those "undefined" type of errors you want to console.log 'this' (console.log(this)) to see which scope 'this' points at and then decide a fix.
In your case I would use fat arrow function assignment for handleSubscriptionChange method:
instead: handleSubscriptionChange(data:any) => {...}
do: handleSubscriptionChange = (data:any) => {...}
Fat arrow function doesn't create its own 'this' and in this case should solve you problem.
I am having two errors when I try to access the elements of a returned object.
errors are : Cannot read property '_id' of undefined
Cannot read property 'getHostNode' of null
This is first part of the code where I extract data from mongoDB into ContactView Component
componentDidMount(){
let contactList = 'http://localhost:5000/v1/contacts';
let callHistory = 'http://localhost:5000/v1/call-history';
axios.all([
axios.get(contactList),
axios.get(callHistory)
])
.then( axios.spread((list, history) => {
console.log(list.data);
console.log(history.data);
this.setState({contactList: list.data, callHistory: history.data});
}))
.catch(function (error) {
console.error(error);
});
}
render() {
return (
<BrowserRouter>
<Switch>
<Route exact path="/contact/:id" component={(props)=> <ContactView contactList={this.state.contactList} id={props.match.params.id} />} />
</Switch>
</BrowserRouter>
);
}
In the ContactView component, I have
contactId(){
const contactList = this.props.contactList;
const contact = _.find(contactList, contact => {return contact._id === contact._id});
this.setState({contact: contact});
console.log(this.state.contact) //works well at all times
console.log(this.state.contact._id) //works initially but returns an error when I refresh on the contact/:id route
}
when I console.log(this.state.contact) I get the object returned to me properly without errors
{_id: "5a232cea94aff40b907fc69b", name: "Dustin Briggs", phone_number: "+185738960158", address: "10 Satin road, Milky-Way 85701, USA"}
but when I try to access the elements in the object or do something like this console.log(this.state.contact._id) I don't get an error navigating from the root to the page but when I refresh on the page an error occurs;
I get both errors
Uncaught TypeError: Cannot read property '_id' of undefined
Uncaught (promise) Cannot read property 'getHostNode' of null
Please I need help to know what I'm doing wrong to fix this bug, which only occurs when I refresh on the contact/:id route
"I don't get an error navigating from the root to the page but when I refresh on the page an error occurs;"
This is happening because when you are in root, on componentDidMount you got the data and then you are going to the page with data. But when you are directly going to the page, page is trying to access the data while it is still being fetched. So this intermediate state is causing error.
To avoid these error you can sanitize your data. As in before extracting data check if the key even defined or not. For example.
const contactList = this.props.contactList || [];
const contact = _.find(contactList, contact => {
return contact && contact._id === contact._id
});
I have a WorkFlow Service hosted in a server: http://myServer.net/MyWorkflowService.xamlx
and it's working normally, I called it from a Windows Phone app before and working.
Now, I wanted to call it from a PCL Project (profile 78) for Xamarin.
I got this error:
A correlation query yielded an empty result set. Please ensure
correlation queries for the endpoint are correctly configured.
I added it as a service reference, and I call an Async Method, and subscribes for completed event:
example
TaskCompletionSource<MyResponse> tsk = new TaskCompletionSource<MyResponse>();
WorkFlowService.SubmitModel serviceModel = new WorkFlowService.SubmitModel()
{
List = MyList.ToArray<string>(),
Guid = Guid,
Description = Description,
userid = UserId
};
WorkFlowClient.SubmitCompleted += (sender, eventArgs) => {
if (eventArgs.Error != null)
{
Debug.WriteLine("Exception : DataService : Adding New" + eventArgs.Error.Message);
tsk.TrySetResult(new MyResponse() {
HasError = true
});
}
else
{
tsk.TrySetResult(new MyResponse()
{
HasError = false
});
}
};
WorkFlowClient.SubmitAsync(new WorkFlowService.SubmitRequest((serviceModel)));
return tsk.Task;
I should send an array of strings with my request, Should I provide ServiceReferences.ClientConfig file and what is the build action for it inside the PCL?!