-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic browser support #6
Conversation
Added basic browser support so no error is thrown in browser
After looking at pull request #2 I agree that the plug-in should not just crash on a platform that is not supported. It makes more sense to just include dependencies on platforms that are supported and do nothing on ones that are not supported. I have updated my pull request to include those changes. |
I was about to let you know about #2. |
That works for me. I updated the pull request with the changes so you can merge them. |
@pke
|
@becvert yes I still wonder why the browser platform would crash with the module in the global section?! |
I found that the device-name.js was not able to be loaded. It makes sense that cordova would not add any cordova-plugin-device-name files to browser builds if browser was not supported by the plug-in. |
To sum up:
note that even with the first option, on failure (very unlikely though), the app will crash. What do you think? |
I do not get any alert box because device-name.js does not exist. That is my issue; device-name.js is not bundled with the browser build so no error handling is taking place. I do get the Cordova logs in my console and as a result of the errors Cordova does not fire any events.
|
I suppose You get an alert box when |
@becvert Why not create a simple proxy file like the one for Windows and just return "Browser" as the name? module.exports = {
get: function getDeviceName(success, fail) {
return success({
name: "Browser"
});
}
};
require("cordova/exec/proxy").add("DeviceName", module.exports); Should solve the problem effectively and without hackery. Or, in a second step return the device name based on the browser user agent? I'm sure there is a lib out there that can vaguely decipher user agents like google analytics does. |
@pke, in that case we need to support all other platforms too. I do not want to do that. The cordova-plugin-device is already deciphering the user-agent I think. I'll move the js-module to the supported platforms and then it's the developer's responsability to know if they can call the api in their app depending on the platform it's running on. |
release 1.2.0 |
Added basic browser support so no error is thrown in browser. Currently I have to manually remove this plugin from Cordova before I can build for browser. This will fix the issue.