Is it possible to utilize native iOS functionalities within JavaScript in PhoneGap version 2.7.0 with CDVPlugin?

I am currently developing a phonegap 2.7.0 web application in xcode 4.5.2 for iOS 6. One of the key features of my web application is video recording with a duration of six seconds. To achieve this, I followed the process outlined on "https://github.com/piemonte/PBJVision".

Now, I am working on integrating native iOS functionalities with Phonegap using CDVPlugin. Specifically, when a user clicks on a camera icon on the homescreen.html page, it triggers an onclick event and calls the -(void) _setup() method in the PBJViewController.m file. This action results in hiding the main screen and displaying the camera options with a custom design.

To accomplish this, I placed several files including PBJViewController.h & PBJViewController.m, PBJStrobeView.h & PBJStrobeView.m, PBJVisionUtilities.h & PBJVisionUtilities.m, as well as PBJVision.h & PBJVison.m into the plugins folder.

Subsequently, I created a JavaScript file named PBJViewController.js and added it to the www folder.

PBJViewController.js

function PBJViewController()
{

}


loadingalert.prototype._setup = function()
{
    //this.resultCallback(res);
    cordova.exec("PBJViewController._setup");
}


cordova.addConstructor(function() {

                       if(!window.plugins)
                       {
                       window.plugins = {};
                       }
                       //window.plugins.loadingalert = new PBJViewController();
                       window.loadingalert = new PBJViewController();
                       });

Following that, I implemented calling code in the video() function within the homescreen.html file.

homescreen.html

  function video()
  {
       alert("video function");

      $('#loader').hide();
      $('#divcontroller').hide();
      $('#menuid').hide();
      $('#home_feeds').hide();

      loadingalert._setup();
      //window.plugins.loadingalert._setup();



      //objloading._setup();
      //window.location = "js-call:myObjectiveCFunction";
  //window.location.href='video.html?user_id='+userid+'&fb_token='+getValue("fb_token");
  }

Furthermore, I made some modifications in the PBJViewController.h file.

PBJViewController.h

   #import <UIKit/UIKit.h>
#import <Cordova/CDVPlugin.h>

@interface PBJViewController : CDVPlugin <UIWebViewDelegate>
{
     IBOutlet UIWebView *webView;

}

-(void)_setup:(NSMutableArray*)paramArray withDict:(NSMutableDictionary*)options;

@end

And In PBJViewcontroller.m file

    #import "PBJViewController.h"
#import "PBJVision.h"
#import "PBJStrobeView.h"
#import <Cordova/CDVPlugin.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <MediaPlayer/MediaPlayer.h>

// Remaining content from the original text...

In the process of implementing these changes, I encountered a warning message stating 'CDVPlugin' may not respond to 'viewWillAppear:' due to replacing CDVPlugin for UIViewController "@interface PBJViewController : CDVPlugin". Additionally, I included the plugin names and values in the config.xml file.

These details offer insight into one aspect of my project. Despite my efforts, I have not yet achieved the desired outcome. I welcome any suggestions or solutions you may have. Thank you.

Answer №1

One way to invoke a plugin method is by using the following syntax:

cordova.exec(null, null, "PBJViewController", "_setup", [])

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Methods for showing variables in AJAX

I need assistance with my form that captures 6 numbers from users and saves them as variables upon submission. I am currently utilizing AJAX to show a loading screen. Is there a way to display the entered numbers on this loading screen using the beforeSe ...

Easily visualize the JSON object hierarchy within Eclipse using JavaScript

Is there a way to view the JSON parse objects structure in Eclipse without using console.log() in Chrome due to cross domain issues? I need assistance with how to view the [object Object] returned structure from Json.Parse. ...

Utilizing PHP for Long Polling within AJAXcreateUrlEncodeProtect(chr(

Utilizing AJAX to refresh specific parts of a page without the need for constant reloading. However, I aim for the table to only refresh upon detecting changes (a concept known as long polling). Despite attempting to implement loops with break statements, ...

Issue with VueJS on Internet Explorer version 11 - SCRIPT1004 error: Missing semicolon

Internet Explorer 11 Error: SCRIPT1004: Expected ';' Hello there! My website is functioning properly on all browsers except for Internet Explorer. Below is the content of my babel.config.js file: module.exports = { presets: [ ['@vue ...

The Angular ui-calendar introduces an innovative approach to event addition, providing users with

I need help with adding events to the angular ui calendar. Currently, I am using $scope.events.push() method to add events, but they get reset when changing the month. If anyone has experience with angular ui-calendar and event addition, please provide ...

Trigger a segue when the Back button is pressed

Is there a way to trigger a segue when the Back button is clicked? I've tried using this code: override func didMoveToParentViewController(parent: UIViewController?) { self.performSegueWithIdentifier("fromGalleryToBody", sender: self) } Unfortun ...

Troubleshooting issue with parsing MySQL data in HTML table using Node.js

Seeking Assistance! I am currently in the process of developing a node file that displays data from MySQL on an HTML page with a search bar. My issue is that sometimes when I run the code, enter something into the search bar and hit the button, it works s ...

What is the best way for the parent component to initiate an http call, update its state, and then distribute that state to all child components

Recently, I encountered an issue while trying to call axios.get('{link here}') from the componentDidMount() method of the parent component: class Parent extends React.Component { constructor(){ super(); this.state = { stuff: [] } ...

Webstorm 2016.1 encountering difficulties accessing JavaScript files

Recently, I upgraded my Webstorm to version 2016.1.1 and everything seemed to be working well. However, I encountered an issue where I can't open any of my *.js files in the editor. Despite restarting Webstorm and my computer multiple times, as well a ...

Interactive Map Displayed within a Pop-up Window

Recently, I developed a custom Google map where points are plotted and an HTML popup window appears when the image is clicked. Now, my goal is to open a file with JavaScript functions inside a lightbox/fancybox when a user clicks on an image. Below is th ...

HTML Image Mapping Up Close

Is there a way to magnify an HTML Image Map with zoom-in functionality similar to jQZoom? I attempted to modify the jQZoom code, but it resulted in losing the Image Map links and only linking to the enlarged image. Any suggestions or assistance would be ...

The mongoose is able to access various collections at once and perform complex computations

Below is the code snippet: module.exports.comparator = function(req, res){ Buyer .find() .exec(function (err, buyer) { if (err) { console.log("Error finding buyer"); res .status(500) ...

Ways to define properties in backbone entities

As I work on my app using backbone, I'm encountering a challenge that might be due to a misunderstanding on my part. I am trying to set specific attributes like titles while also having default values in place. However, it seems that the custom attri ...

What is the solution for resolving a jQuery scroll animation glitch?

I have a piece of code that successfully takes me back to the top of the page, but it lacks animation. Can anyone provide assistance with adding animation to this function? $('.topScroll').click(function(){ $("html, body").animate({scrol ...

Dynamically changing the borders of WebGL canvases: a guide to adding and

Here is my code snippet for creating an HTML canvas: <canvas id="glCanvas" class="canvases" width="20" height="20></canvas> To set the color, I am using the following: gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); I am w ...

How can you customize the output of JSON.stringify for objects in JavaScript?

What steps can be taken to customize the default output of JSON.stringify for an object? ...

What steps should I take to transfer the loadCategories() function from the SomeViewController to the SomeViewModel?

Seeking advice on transitioning a function from SomeViewController to SomeViewModel: var categoryArray: [Category] = [] private func loadCategories() { downloadCategoriesFromFirebase { (allCategories) in self.categoryArray = allCategories ...

Instructions for developing an offset plugin for an HTML5 video player

I'm currently working on developing an offset plugin that allows playing a specific portion of a video in an HTML5 video player. While there is an existing plugin for video.js available at videojs-offset plugin, I am now experimenting to adapt this p ...

Encountering a problem when trying to parse a string array from the server's response

After receiving an API response, I am dealing with a JSON string that looks like this... ["products": <__NSArrayI 0x7fa103868000>( { barcode = HDz; "category_json" = "[{\"category_name\":\"Home\",\"ca ...

Struggling with using flexboxes and creating animated elements

Seeking assistance with animating the search bar on a website project. The animation is functioning, but the search input abruptly moves when the animation starts, as shown in this GIF: https://i.sstatic.net/17sFl.gif I am utilizing jQuery for the animat ...