Missing params from body when sandbox environment - apple-push-notifications

We are implementing push server notifications and during our tests we are getting way too few parameters in json from apple which makes it impossible to identify the subscription.
Table 6.3 in their documentation claims that body contains several params amongst original_transaction_id, latest_receipt, latest_receipt_info etc.
Though, we are only getting for INTERACTIVE_RENEWAL type:
{
"auto_renew_product_id": "agreement_chat_MO_auto_renewal",
"password": "CORRECT_PASSWORD_HERE",
"environment": "Sandbox",
"auto_renew_status": "false",
"notification_type": "INTERACTIVE_RENEWAL"
}
and for DID_CHANGE_RENEWAL_STATUS type:
{
"auto_renew_status_change_date": "2019-06-03 08:13:11 Etc/GMT",
"environment": "Sandbox",
"auto_renew_status": "false",
"auto_renew_status_change_date_pst": "2019-06-03 01:13:11 America/Los_Angeles",
"password": "CORRECT_PASSWORD_HERE",
"auto_renew_status_change_date_ms": "1559549591000",
"auto_renew_product_id": "the_product_id",
"notification_type": "DID_CHANGE_RENEWAL_STATUS"
}
Given those params, it is impossible to find the subscription the notification refers at.
Am I missing something here? Is the sandbox broken in any way?

You are not the only one...
https://forums.developer.apple.com/thread/116996
It has been broken in Sandbox for days now. We checked our logs and they had this error in production for some time. Now in production it seems to be fixed, but the problem persists in Sandbox.

Related

Replying with SSML for Phone Gateway

As part of my response JSON, I am sending the following to the Dialogflow CX Phone Gateway:
"fulfillmentResponse": {
"messages": [
{
"outputAudioText": {
"ssml": "<speak>That is <break time=\"500ms\"/> <emphasis level=\"strong\">correct</emphasis></speak>",
"allowPlaybackInterruption": true
}
},
{
"outputAudioText": {
"ssml": "<speak>What would you like to do now?</speak>",
"allowPlaybackInterruption": true
}
}
]
}
If I understand the documentation for ResponseMessage correctly, then these should be used for audio output.
But if the OutputAudioText object are the only messages included, then nothing is said in response. If I then add a Text object, then the (plain) text object is used for TTS.
Is SSML actually supported for the Dialogflow CX Phone Gateway? If so, how?
This appears to be a known bug at the moment.
See the thread on twitter which is partially excerpted below.
From Lee Boonstra: I tested this, and I can reproduce. I wouldn't be surprised if this is a bug since the telephony gateway is still in early preview and the output audio text seems to be a new feature. - I am checking it with the team.
From Lee Boonstra: Yes, I can confirm myself :) - the bug was already filed. Will be fixed very soon, but for the competition you will likely not been able to use SSML in the phone gateway. (It depends per integration tho)
From Allen "Prisoner" Firstenberg: Thanks for checking on and confirming this, Lee! Very much appreciated. To make sure I'm on the right track, "outputAudioText" is the correct way to do this?
From Lee Boonstra: Yes it is, and it takes a string with <speak> tags

Zapier CLI Trigger - How to use defined sample data when no results returned during setup

I am trying to prototype a trigger using the Zapier CLI and I am running to an issue with the 'Pull In Samples' section when setting up the trigger in the UI.
This tries to pull in a live sample of data to use, however the documentation states that if no results are returned it will use the sample data that is configured for the trigger.
In most cases there will be no live data and so ideally would actually prefer the sample data to be used in the first instance, however my trigger does not seem to ever use the sample and I have not been able to find a concrete example of a 'no results' response.
The API I am using returns XML so I am manipulating the result into JSON which works fine if there is data.
If there are no results so far I have tried returning '[]', but that just hangs and if I check the zapier http logs it's looping http requests until I cancel the sample check.
Returning '[{}]' returns an error that I need an 'id' field.
The definition I am using is:
module.exports = {
key: 'getsmsinbound',
noun: 'GetSMSInbound',
display: {
label: 'Get Inbound SMS',
description: 'Check for inbound SMS'
},
operation: {
inputFields: [
{ key: 'number', required: true, type: 'string', helpText: 'Enter the inbound number' },
{ key: 'keyword', required: false, type: 'string', helpText: 'Optional if you have configured a keyword and you wish to check for specific keyword messages.' },
],
perform: getsmsinbound,
sample: {
id: 1,
originator: '+447980123456',
destination: '+447781484146',
keyword: '',
date: '2009-07-08',
time: '10:38:55',
body: 'hello world',
network: 'Orange'
}
}
};
I'm hoping it's something obvious as on scouring the web and Zapier documentation I've not had any luck!
Sample data must be provided from your app and the sample payload is not used for this poll specifically. From the docs:
Sample results will NOT be used for a user's Zap testing step. That
step requires data to be received by an event or returned from a
polling URL. If a user chooses to "Skip Test", then the sample result,
if provided, will be used.
Personally, I have never seen "Skip Test" show up. A while back I asked support about this:
That's a great question! It's definitely one of those "chicken and
egg" situations when using REST Hooks - if there isn't a sample
available, then everything just stalls.
When the Zap editor tries to obtain a "sample result", there are three
places where it's going to look:
The Polling endpoint (in Step #3 of your trigger's setup) is invoked for the current user. If that returns "nothing", then the Zap
editor will try the next step.
The "most recent record/data" in the Zap's history. Since this is a brand new Zap, there won't be anything present.
The Sample result (in Step #4 of your trigger's setup). The Zap editor will tell the user that there's "nothing to show", and will
give the user the option to "skip test and continue", which will use
the sample JSON that you've provided here.
In reality, it will just continue to retry the request over and over and never provide the user with a "skip test and continue" option. I just emailed again asking if anything has changed since then, but it looks like existing sample data is a requirement.
Perhaps create a record in your API by default and hide it from normal use and just send back that one?
Or send back dummy data even though Zapier says not to. Not sure, but I don't know how people can set up a zap when no data has been created yet (and Zapier says not many of their apps have this issue, but nearly every trigger I've created and ever use case for other applications would hint to me otherwise).

DeleteButton triggers "Incorrect Element"

I'm implementing an asp.net core API with admin-on-rest.
A custom REST client communicates to the API endpoints, but the mapping is fairly standard.
When I try to implement a into the interface, the deletion of elements works fine. Still, I get an error on every edit or deletion view for an element with the following text: "Incorrect Element". The console is empty, and everything works as expected.
What causes the error - and how can I solve this?
I've attached a screenshot of the error popup.
Screenshot of the error
Update 1:
Here is the code of my custom REST client: customrestclient gist and the included fetch.js: fetch.js
Double check your custom restClient returns at least the id of the deleted resource inside a data object.
I was finally able to fix the issue. One of my API endpoints returned a list instead of a single element for one of my ReferenceInput-elements.
This was the content response before my change:
[{
"languageId": 2,
"id": 2,
"name": "Danish",
"isoCode": "dan"
}]
And this is the correct response, that does not trigger the error:
{
"languageId": 2,
"id": 2,
"name": "Danish",
"isoCode": "dan"
}

Receiving and responding to Twilio SMS using parse cloud module

I have a cloud code function that I use to send a text message to a number that is determined in my app (iOS).
The message sends fine, but I want the person who receives the message to be able to respond so that the original sender sees their response. I'm having trouble finding a way to do this using the Parse twilio module.
Here is what my cloud code function looks like right now:
Parse.Cloud.define("sendText", function(request, response) {
// Use the Twilio Cloud Module to send an SMS
twilio.sendSms({
From: "+15555555555",
To: request.params.number,
Body: request.params.message
}, {
success: function(httpResponse) { response.success("SMS sent!"); },
error: function(httpResponse) { response.error("Uh oh, something went wrong"); }
});
});
Is it possible to just call this function again from its callback with the new recipient's number (the number of the original sender)?
Twilio developer evangelist here.
It seems you're trying to create what we call the masked phone numbers feature. This is a feature in which two users communicate through a central Twilio number and never find out each others' details. There is a tutorial on how to accomplish this with both calls and SMS messages however it is in Ruby on Rails. I recommend you take a read through as it gives you a good idea of how you'll need to implement this.
Then, if you have any more Parse/Node.js related questions on how to work on it, please drop me a line at philnash#twilio.com.
Check out this question/answer I posted with a similar issue.
I use Twilio to anonymize calling and texting between users of my app. There's more info in my app about how I do this, but let me know if you have some questions.
If you want to know who sent the message you need the recipient to be able to get the sender's number, so he can call the function again himself.
There are many ways to do that, your idea seems alright, you could add the sender's phone number as a parameter in the cloud function, and use it in the call back when you use sendSMS a second time.
Here is one way to do it :
Parse.Cloud.define("sendText", function(request, response) {
// Use the Twilio Cloud Module to send an SMS
twilio.sendSms({
From: "+15555555555",
To: request.params.recipientnumber, //Notice I changed the paramter name here
Body: request.params.recipientmessage //Notice I changed the paramter name here
}, {
success: function(httpResponse) {
twilio.sendSms({
From: "+15555555555",
To: request.params.sendernumber, //Notice I changed the paramter name here
Body: request.params.sendermessage //Notice I changed the paramter name here
}, {
success: function(httpResponse) {
response.success("SMS sent!");
},
error: function(httpResponse) {
response.error("Uh oh, something went wrong");
}
});
},
error: function(httpResponse) {
response.error("Uh oh, something went wrong");
}
});
});
If the first call succeeds, make another one, if that one succeeds, return success. If either fail, return failure and never start another call.
But make sure you understand this, this will pretty much send both sms at the same time, most of the time. Your sender won't get the feeling that it was a response (or it was a fast one !).
I'm not sure I understand exactly what you're trying to achieve, that's why I posted some comments to suggest something else, but I still wanted to answer here about your exact question.

How do I retrieve step count data from Google Fitness REST api?

Since I installed the Google Fit app on my Nexus 5 it has been tracking my step count and time spent walking. I'd like to retrieve this info via the Google Fitness REST api (docs) but I can't work out how to get any of that data from the REST api.
I've used the OAuth 2.0 playground to successfully list dataSources but none of the examples I have tried have returned any fitness data whatsoever. I feel like I need to use something similar to a DataReadRequest from the (Android SDK) but I'm not building an Android app -- I just want to access fitness data already stored by the Google Fit app.
Is it even possible to get the data gathered by the Google Fit app? If so, how can I read and aggregate step count data using the REST api?
It turns out that the answer is in the docs after all. Here is the format of the request.
GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
The only supported {userId} value is me (with authentication).
Possible values for {dataSourceId} are avaiable by running a different request.
The bit I missed was that {datasetId} is not really an ID, but actually where you define the timespan in which you are interested. The format for that variable is {startTime}-{endTime} where the times are in nanoseconds since the epoch.
I was able to get this working by going through the google php client and noticed that they append their start and finish times for the GET request with extra 0's - nine infact.
Use the same GET request format as mentioned in an answer above:
https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
Now here is an example with the unix timestamp (php's time() function uses this)
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368-1471080168
This is the response I get:
{
"minStartTimeNs": "1470475368",
"maxEndTimeNs": "1471080168",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
}
However if you append your start and finish times with nine 0's that you put in your GET requests and shape your request like this:
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368000000000-1471080168000000000
It worked - this is the response I got:
{
"minStartTimeNs": "1470475368000000000",
"maxEndTimeNs": "1471080168000000000",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"point": [
{
"modifiedTimeMillis": "1470804762704",
"startTimeNanos": "1470801347560000000",
"endTimeNanos": "1470801347567000000",
"value": [
{
"intVal": -3
}
],
"dataTypeName": "com.google.step_count.delta",
"originDataSourceId": "raw:com.google.step_count.delta:com.dsi.ant.plugins.antplus:AntPlus.0.124"
},
The response is a lot longer but I truncated it for the sake of this post. So when passing your datasets parameter into the request:
1470475368-1471080168 will not work, but 1470475368000000000-1471080168000000000 will.
This did the trick for me, hopes it helps someone!
I tried post method with below URL & body. This will work, please check inline comments too.
Use URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Method: POST
Body:
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 }, // This is 24 hours
"startTimeMillis": 1504137600000, //start time
"endTimeMillis": 1504310400000 // End Time
}

Resources