Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 15    Views: 77

Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
08/28/13 10:56 AM (12 years ago)

Custom URL Plugin - HELP

Hi all, I created my app in BuzzTouch and used the customURL plugin. I've downloaded the code, and am looking in particular at the BT_Screen_CustomURL files (.h and .m). What I need to do should be quite simple, but for the life of me I can't find the right lines in the code to accomplish it... here is what I need to do: 1) When buttons 1, 2 or 3 are pushed, it should load the URL in webView, but I want the webview to be hidden from the user. 2) When button 4 is pressed, load URL like normal, showing the webView. Sound easy, right? Lol, that's what I thought. I can't seem to get it to work. Any advice? Also, if you are wondering why I would hide the webView from the user, it's because the URL in the first three buttons only sends data, which the user does not need to see anything after the button is pressed. It actually ineracts with a slot machine over an IP address, and the commands are sent via URL to change the volume, lock the machine, etc... so when they press those buttons, they will see the results on the slot machine, no need to see them in a browser. Thanks, Dave
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/28/13 03:40 PM (12 years ago)
Can you illustrate this somehow? I can't quite figure out what you're asking. Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/28/13 03:56 PM (12 years ago)
Hey Smug, Basically, my main menu only has 4 buttons. They are all using the customurl plugin to simply load a web page. The problem is, I need this page to load in the background, not visible to the user. Basically the UIwebView needs to be hidden (I suppose in xcode as something like UIwebView.hidden=YES). Currently, when I run the app, it shows the main menu, and when tapping a button, it loads another screen that has a uiwebview control on it in full screen. I was able to modify the size of the webview control to 0, which does make it go away, but it shows me a blank background view instead of going back to the main menu showing my buttons. Ideally I would like to just have it send the URL to the UIwebview and have the actual control (browser window) hidden from the user. I would just need button #4 to behave normally though, but we can figure that out after the other part. I've uploaded the xcode source here: http://www.angryninjas.com/cloud/TITO-Slots.zip (it's only 2 megs) Lastly, once I get the above figured out, I'd like a text box at the bottom of the main menu (or even better, a button to a settings screen) where users can input their IP address, which saves as local data, and that would be used as a variable in the URL... right now the URL is hardcoded (in the code, you'll see the url is 192.168.1.200/?"InsertCommandsHere". Eventually I'll just need to have it so the user can enter their IP in a text field, and the 192.168.1.200 gets replaced with whatever they enter. Sounds fairly easy, but I only know enough Objective C to be dangerous, lol.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/28/13 11:30 PM (12 years ago)
Well basically you're thinking two screens, not one. One screen for the buttons, and another screen for the HTML display, if that's what you're looking to do. I'm not sure why you want a web page to load but not display; it's just as easy 'not' have it load until it's time. You can't have two screens active anyway, BT or not. So have the buttons on screen 1, and the HTML on screen 2. Screen 1 can be a menu screen, or you can use something like Chris1's HTML Pro plugin, for the menu buttons. Danny's BTA Menu might also be a viable choice. For the user preferences I'd just lookup how to use NSUserDefaults. It's not hard. And if you 'really' want to be dangerous, check out David's video on how to build a plugin. It's pretty fascinating, and got me up to speed fairly fast. Of course, I had to pause and replay a few times, lol! http://www.youtube.com/watch?v=OJrMVTn8z0s Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 08:58 AM (12 years ago)
Thanks Smug, I think that the way the CustomURL plugin work, it uses two screen. I can't tell if the browser shows in a new screen or if it's like an actionsheet overlay. If it's two screens, that would make sense as to why when I make the browser window (UIwebView) size 0, it doesn't show my buttons, only a blank background. I get confused when code doesn't have a .XIB for the screens, or no storyboard to visibly see the different screens. The reason for not showing the user the web page is because the buttons simply use a URL to send data to a slot machine... It does not need to show the user anything. Showing the user the page will simply frustrate them, since they will have to click Back each time after the button press. For example, lets say I have a "Volume Down" button. If it popped up the web page display each time they pressed the button, and they wanted to turn the volume down 5 clicks, they would have to click "volume down, back, volume down, back, volume down, back, volume down, back, volume down, back". Think of it like a TV remote. I've seen code in the past where they simply had to put something like: UIwebView.hidden=YES But I've tried adding that to the end of the viewdidload, as well as making the UIwebView control size 0... but I end up getting just a blank view background, and not my main menu with the buttons. I can't seem to figure out how to have it NOT show the UIwebView, and just load the URL in the background while staying on the same view with all my buttons. Could you possibly take a look at the sample code I uploaded above and let me know where I'm going wrong?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 01:46 PM (12 years ago)
I'm pretty sure the custom url only shows one screen, at least, one at a time. It doesn't need a xib file because the components are created in the code. Ok, so you don't need to show them the page, so just don't load it. What is the web page supposed to do, if you don't want to show the user? Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 02:58 PM (12 years ago)
When the URL loads, it simply sends commands to a slot machine hooked up to the users network. The machine with that IP address knows what to do by what URL was loaded. A browser displayed to the user has no use... as long as the machine sees that the URL was sent. So I can't simply not load it, the URL must be sent in order for the machine on the network to see that it's been issued a command. Any recommendations?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 03:22 PM (12 years ago)
You don't have to use a web page just to send a URL... or to receive data from one. A little google can go a long way ;) http://deusty.blogspot.com/2006/11/sending-http-get-and-post-from-cocoa.html Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 03:25 PM (12 years ago)
Ah, ok, i assumed the URL had to load in a UIwebView. I'll take a look at it now. I'm hoping it's simple copy and paste, because I don't know Objective C well enough yet... hence the reason I went with BT. Thank for your help.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 03:29 PM (12 years ago)
Yeah, pretty much over my head. Now I'm completely confused, lol. Is there anything in BT that I can use to accomplish the desired effect?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 03:49 PM (12 years ago)
Off the top of my head, no one has built a slot machine plugin that I'm aware of ;) You'll have to think of Buzztouch as sort of a 'shell' application that can be modified. Although people call it a framework, in essence it really isn't. If the BT plugins available can do what you need to do, you're golden. But if they don't, then you'll need to modify the plugin to do what you want, create a new plugin to do what you want, or hire someone to build a plugin to do what you want. Currently there are about 90 plugins available, and in the near future when the market opens again there will be even more. My first app was built entirely with plugins available within Buzztouch. My second employed a plugin I built, that took a good while to finish. But it was a learning experience. I'm 3 months into my next app, and it's taking me forever, lol! My advice would be "don't give up your dream", but ground your path with reality. Start off taking inventory of what is available NOW and figure out what you'd like to build with it. As you can experience, you can venture into new directions. There are literally thousands of apps in the app store using nothing but stock bt plugins; it just matters how you use them. If you're good with PHP and the server side of operations, you can probably get most of this done on the back end, and let the app just be a pretty 'showcase' for what's going on inside the server. But sooner or later, if you want to do this inside the app, you're going to have to get familiar with Xcode and java. Check out Ray Wenderlichs tutorials; they're pretty good. <a href="http://www.raywenderlich.com" target="_blank" rel="nofollow">http://www.raywenderlich.com</a> And it's not hard; it's just confusing. Most of my mistakes in code are syntax driven. Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 03:51 PM (12 years ago)
Lol, yeah, I know theres no slot machine app... was wondering if there was a get/post plugin or something for BT
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 04:00 PM (12 years ago)
In that situation you're looking at some custom code, probably. If you want someone to build it for you, you'll want to setup a flowchart on how the app is supposed to work, how the plugin will interact with that app, and any outside resources. If you're good in PHP and the backend of the server, you might think about having PHP do all the heavy lifting on your server, and just use an HTML 'front end' to handle the user interaction. If you still want to figure out a way to do this in xcode (or Java), I often go to 'github' and find something similar to what I want to do, and then use bits and pieces to get my idea closer to the device. https://github.com/search?l=Objective-C&q=slot+machine&ref=cmdform&type=Repositories Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/29/13 04:51 PM (12 years ago)
Thanks, I'll look around. I already have scripts that handle everything. The only thing I need the app do do is launch a URL that the user doesn't see, either with post command, or even a hidden uiwebview. The server handles everything else already. The only job of the app is to have 4 buttons, each button launches a URL that isn't visible to the user. That's it. Isn't there a simple line of code that I can edit in my existing customurl code that says to hide the displayed web page view once the URL has been sent? Everything else is handles server side and functions perfectly. I just need to hide the displayed screen (view)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 06:33 PM (12 years ago)
If that's the case, you might look into modifying the blank plugin. take a look at David's video 'how to make a plugin' (the link is in an above comment) and then create and modify a xib file to display the buttons. In the code, all you really need to do is handle the clicks, send and receive the information from your server. Keep in mind that the web protocol (http) is merely a way to talk, it doesn't 'require' you to use a webpage. that's just the most common use. Its not as easy as it sounds, but it's not too difficult. In any event you're going to have to do some digging to learn what you need in order to accomplish this. If there was a way around it I would have already gone that path ;) Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
09/02/13 03:07 PM (12 years ago)
Hey there Ninja, Just to muddle the waters a bit more, you could implement a Custom URL Scheme and use that custom URL for the first three buttons. Your custom URL Handler would be the one sending the Slot Machine URL to your Server in the background. Go take a look at last night's creation at this post: http://www.buzztouch.com/forum/thread.php?tid=BCDE1D48251134A33175B7C&currentPage=2 After you bounce that idea around in your head, come on back. We shall get you sending HTTP commands to the Slot Machines fairly soon! :-) @Smug -- hopefully you see where I'm going with this? Let me know I am off track! -- Niraj
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.