Namespace change in Google Cast custom sender application - javascript

I have an issue with a custom sender/receiver application was written a while back.
We recently merged to the cloud and the sender application which is a simple web page was moved and changed its URL from what it used to be.
http: //sdpc.webpage.com to what it is now https: //webpage.com/sdpc.
Now it appears my messages are not being sent over to the receiver application.
I have the following code to send the message to the receiver:
var applicationID = 'F7000000';
var namespace = 'urn:x-cast:com.webpage.cast.sdpc';
var session= null;
var driverRequest;
function sendMessage(message) {
if (session != null) {
location.reload();
session.sendMessage(namespace, message, onSuccess.bind(this,
"Message sent: " + message), onError.bind(this, "Error: " + message));
// $('messageDiv').set('html', session.sendMessage(namespace, message, onSuccess.bind(this, "Message sent: " + message), onError));
} else {
chrome.cast.requestSession(function(e) {
session = e;
location.reload();
session.sendMessage(namespace, message, onSuccess.bind(this,
"Message sent: " + message), onError.bind(this, "Error: " + message));
// $('messageDiv').set('html', session.sendMessage(namespace, message, onSuccess.bind(this, "Message sent: " + message), onError));
}, onError);
}
}
this all worked before we moved the folder over to what is now it's new location on the cloud. I made sure to change the receiver URL in the developer google console to point to its new location, but no luck. Could the namespace be the issue? It's the only thing I'm not sure about.
I believe the sender to receiver connection isn't even being established because I have code setup for any errors while displaying the image to the chrome cast and I am not seeing anything.
I've looked on the google forums and GitHub but I can't think of anything else that might be causing this issue.

not really sure why this got flagged down without letting me know why.
However I managed to solve my own question in case anyone ever needs it. As it turns out my web page was internal so by changing the url on the developer's google web page the receiver was not able to be reached from the outside world. However as soon as I transferred the project + url to a public facing web page and it worked. It took a couple of hours before it registered but it worked.

Related

What is dnndev.me? (React Native Share link on Facebook shows as dnndev.me)

I'm currently working on a simple share function where I can share a news article via the URL (I.E. https://www.nrps.nl/Nieuws/Nieuwsitem.aspx?ID=812). I'm using React Native Share for this (code below). When sharing on Facebook it shows up as dnndev.me instead of nrps.nl, what I expected it to be. Clicking the dnndev.me link redirects to https://www.nrps.nl/Nieuws/Nieuwsitem.aspx?ID=812&fbclid=IwAR3Eq-j1wX8GUVvSEvhFNu85k8U_vjmV0l4_ycF-AUhoV61YBIieRGJgQg4 instead of https://www.nrps.nl/Nieuws/Nieuwsitem.aspx?ID=812, but the content is the same. (if I shouldn't show any of this, please edit it out. I don't know what the extra string means)
From what I can tell, dnndev.me seems to be a development environment.
The questions:
What is dnndev.me, besides some sort of host?
Can I do anything to work around it showing up as dnndev.me or can I only inform NRPS that they haven't done so already?
RN code:
let message = `${news.Title}\n${news.Image}\n${news.MessageUrl}`
news.title is a simple string. news.image is a URL to an image, news.MessageUrl is the URL of the news article itself. I've tested it with only the MessageUrl and it has the same result.
try {
const result = await Share.share({
message: `${message}`,
});
if (result.action === Share.sharedAction) {
if (result.activityType) {
// shared with activity type of result.activityType
} else {
// shared
}
} else if (result.action === Share.dismissedAction) {
// dismissed
console.log("Sharing dismissed")
}
} catch (e) {
console.log(e);
}
EDIT:
What I want to happen is to have the auto generated square / content field (or however it's called) like follows:
https://imgur.com/EalEbmZ
dnndev.me is a web server. As a web server, it notifies facebook of any problems in managing and operating facebook data and also solves any problems.
webSite of dnndev.me
And the fbclid behind the existing parameters is the visitor tracking system ID.
The acronym for fbclid is: "Facebook Click Identifier". It means a
Facebook click identifier.
It's about Facebook clicks.
These are parameters introduced for accurate statistics from this data.
We're also going to exchange data with Google Annalysis and AdSense.
Make more accurate estimates of visitors.
To share Facebook, you can use the following modules to work around it: This solution is contained in the Facebook developer's official document.
$yarn add react-native-fbsdk or npm install --save react-native-fbsdk
$ react-native link react-native-fbsdk
Note For iOS using cocoapods, run:
$ cd ios/ && pod install
Usage
import { ShareDialog } from 'react-native-fbsdk';
let message = `${news.Title}\n${news.Image}\n${news.MessageUrl}`
const shareLinkContent = {
contentType: 'link',
contentUrl: "https://www.nrps.nl/Nieuws/Nieuwsitem.aspx?ID=812",
contentDescription: message,
};
...
this.state = {shareLinkContent: shareLinkContent,};
...
shareLinkWithShareDialog() {
var tmp = this;
ShareDialog.canShow(this.state.shareLinkContent).then(
function(canShow) {
if (canShow) {
return ShareDialog.show(tmp.state.shareLinkContent);
}
}
).then(
function(result) {
if (result.isCancelled) {
alert('Share operation was cancelled');
} else {
alert('Share was successful with postId: '
+ result.postId);
}
},
function(error) {
alert('Share failed with error: ' + error.message);
}
);
}

Catch window.open() error

I open a file download from a remote API on my webpage via window.open(). The API (a Flask server) has error handling and returns the error message if there's an internal server error, like this:
#app.errorhandler(502) //all other errors are handled the same way, including 500, etc.
#crossdomain(origin='*')
def bad_gateway_error(error):
return "Bad Gateway Error - Please make sure you're using a properly formatted file! Details: " + str(error), 200
I want to display this error on my site instead of redirecting to the error page. I'm trying to catch it via:
try {
window.open("https://API/receivedoc?timestamp="+timestamp,"_self")
} catch(e) {
filerootdiv.querySelector('.output').innerHTML = String(e);
}
This however does nothing (tested in Chrome). How could I catch the error when I'm using window.open? I guess it might be because in the error handling I return a 200 message so that the string I return actually gets returned instead of just crashing the server (this needs to stay this way as it's working just fine with all the other errors when I'm not trying to return a file). The issue is that I can't tell if the API request would return a file or a string before doing a window.open().
UPDATE
I've tried implementing:
let new_window = window.open("https://flaskmin.run.aws-usw02-pr.ice.predix.io/receivedoc?timestamp="+timestamp,"_self")
newWindow.onerror = function() {
filerootdiv.querySelector('.output').innerHTML = "Error!";
However this still only opens a new window with the error. I guess it's because of the error handling on the server side (I cannot change this). Can I somehow probe the content of new_window before redirecting to it, and just not open it if it's just a string containing the word 'error'?

Windows Azure Notification Hub Error

I have just gotten this error. Everything was working fine up until this morning.
Error: 400 - The request api-version is invalid because the the notification hub was created in an older version. Re-create the notification hub.
TrackingId:aaed084f-8c8a-49f1-8246-122763437b63_G7,TimeStamp:5/15/2016 3:56:13 AM"
In my node.js table script I am connecting to the hub like so:
var azure = require('azure');
var hub = azure.createNotificationHubService('hubName','connectionString');
And sending like so:
hub.wns.sendRaw(['public'], JSON.stringify(item), function(error){
if(!error)
console.log("total refresh " + JSON.stringify(item));
else
console.log("error sending total refresh " + JSON.stringify(error));
});
The error response keeps firing. I tried recreating the notification hub but still get the same error.
Does anybody know why? Have Microsoft updated their systems? Do I need to include an update for my javascript windows store application?
Thankyou
The problem is that nodejs sdk doesn't set the api-version at all :)
You can temporarily fix this by commenting these lines in the azure-sb module (or fix it in better way somehow):
azure-sb/lib/servicebusserviceclient.js # line 67:
// Set API version
// if (webResource.queryString[Constants.ServiceBusConstants.API_VERSION_QUERY_KEY] === undefined) {
webResource.withQueryOption(Constants.ServiceBusConstants.API_VERSION_QUERY_KEY, Constants.ServiceBusConstants.CURRENT_API_VERSION);
// } else if (webResource.queryString[Constants.ServiceBusConstants.API_VERSION_QUERY_KEY] === null) {
// delete webResource.queryString[Constants.ServiceBusConstants.API_VERSION_QUERY_KEY];
// }
Anyway, waiting for Microsoft to fix this dumb error...
Yah, thanks #Peter.
I created temp module in root "azure-sb-temp", imported instead of "azure" in my notification service, installed packages "azure-common" and "underscore". The last thing is comment # line 69, 71, 72, 73 at /azure-sb-temp/lib/servicebusserviceclient.js

How do i send a SMS using phonegap without opening the native app?

I am making an SMS app using HTML,CSS, and JAVASCRIPT on intel xdk.
I have tried quite a few SMS phonegap plugins, but all open the native SMS app and the user has to click send again.
Is there anyway i can send the SMS using the above coding languages but without opening the default SMS app?
EDIT : Surprisingly, just moments after posting this question. I found this
CORDOVA SMS PLUGIN
I'm yet to check if it works.
Meanwhile, is there any other method too?
I tried that plugin (https://github.com/hazems/cordova-sms-plugin) and it worked for me. I can't endorse it, but I was able to send a text message without going into the SMS app, though it does show the message in my history of messages in the SMS app.
I just included the plugin as a third party plugin on the projects page and used this code (with a valid number in place of the Xs) :
var mymsg = {
phoneNumber: "XXXXXXXXXX",
textMessage: "Testing"
}
if (typeof sms === 'undefined' || typeof sms.sendMessage !== 'function') {
alert("No plugin");
}
sms.sendMessage(mymsg, function(message) {
console.log("success: " + message);
alert("Sent");
}, function(error) {
console.log("code: " + error.code + ", message: " + error.message);
alert("Error sending");
});

Fine Uploader error with internet explorer 10

I am using Fine Uploader 3.7.0 in a project with Chrome and Firefox and it works fine, but with Internet Explorer 10 the files are uploaded correctly but the user always get the "Upload failed" error message, even with the demo tests:
<script>
$(document).ready(function() {
var errorHandler = function(event, id, fileName, reason) {
qq.log("id: " + id + ", fileName: " + fileName + ", reason: " + reason);
};
var myUploader = new qq.FineUploader({
element: $('#basicUploadButton')[0],
multiple: false,
callbacks: {
onError: errorHandler
},
request: {
endpoint: '/fineupload/receiver'
}
});
});
</script>
<div class="fineUploader">
<span>Please upload your files for automated process.</span>
<div id="basicUploadButton" class="upload-btn"></div>
</div>
<br />
<div>Close Window</div>
I debugged the servlet and I see that I am sending this:
writer.print("{\"success\": true, \"uuid\": \"" + requestParser.getUuid() + "\", \"originalFileName\": \"" + requestParser.getFilename() + "\"}");
so I think that the JSON I am supposed to get is correct.
Any ideas why can this be failing with IE10? I also tried with the compatibility modes and didn't work.
Updated: Console log:
[FineUploader 3.7.0] Error when attempting to parse xhr response text (SyntaxError: Invalid character)
id: blog.jpg, fileName: Upload failure reason unknown, reason: [object XMLHttpRequest]
Thanks!
The problem was due to the JSON response I was creating in Java.
Looking at the Network tab in IE10 developer tools (thanks Ray for the advice) I get:
{"error": "java.io.FileNotFoundException: C:\data\uploads\fd9b5240-5661-4f07-a216-7a76b2250b00_C:\folder\blog.jpg (The filename, directory name, or volume label syntax is incorrect)"}
I was using
writer.print("{\"success\": true, \"uuid\": \"" + requestParser.getUuid() + "\", \"originalFileName\": \"" + requestParser.getFilename() + "\"}");
Instead of that
JSONObject json = new org.json.JSONObject();
json.put("success", true);
json.put("uuid", requestParser.getUuid());
json.put("originalFileName", requestParser.getFilename());
writer.print(json.toString());
works fine with every browser.
Anyway, I needed to avoid the file name that IE10 manages (C:\folder\blog.jpg) so I had to use
json.put("originalFileName", getCorrectFileName(requestParser.getFilename()));
with getCorrectFilename(String s) removing the "C:\folder\" part.
The question of "my file is sent to the server but Fine Uploader reports a failure" is a common one. As the docs state, you MUST return valid JSON in the response to Fine Uploader's upload POST requests. Based on your comments, you were not returning valid JSON. To verify that you are returning valid JSON, you can use a tool such as JSON Lint. You can examine the response payload via your browser's developer tools, or set the debug option to true in your Fine Uploader options.
As #mfeltner stated, you should be using a JSON serialization tool server-side when constructing your response.

Categories