hazemhagrass / phonegap-base64

Plugin to get base64 encoding of any IMAGE, Base64 can be retrieved for any file for android, however for iOS images only supported
19 stars 42 forks source link

Phonegap Build Uncaught ReferenceError: device is not defined Base64.js:11 #6

Open ChrisJaquezOS opened 8 years ago

ChrisJaquezOS commented 8 years ago

Hello. Testing on Android to convert a file the Uncaught Reference error is raised on line 11: I am using PhoneGap Build version 5.2.0

       args.filePath = filePath;
    //handle android using native code because toDataURL is not supported on android version < 3
    if (device.platform == "Android") //Error is raised here
        cordova.exec(sucess, failure, "Base64", "encodeFile", [args]);
    else{

This is my code:

            var url = photos[i][0];
            var description = photos[i][1];
            window.plugins.Base64.encodeFile(url, function (base64) {
                var postData = {
                    'filex': base64,
                    'order': theOrder,
                    'des': description
                }
                console.log(postData);
                $.ajax({
                    url: apiip + 'pictures',
                    headers: {
                        "api-key": apiKey,
                        "shop-id": shopID
                    },
                    type: 'POST',
                    data: postData,
                    success: function (data) {
                        console.log(data);
                    },
                    error: function (xhr, status, e) {
                        console.log(e);
                    }
                });
                console.log("sent ajax request");
            });
maniolias commented 8 years ago

Same error. Have you find the solution?

labibramadhan commented 8 years ago

just install http://ngcordova.com/docs/plugins/device/

aiyuzhou commented 6 years ago

Same error here, any idea?

EDcasa commented 4 years ago

I had the same problem and solutions by installing the Device plugin in ionic

AaryaDevnani commented 4 years ago

same issue, any solution ?