Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 14    Views: 153

Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
01/20/17 06:56 AM (7 years ago)

Custom URL - Link to another plugin

Hi, actually in my app I use non tabbed layout with a custom url. I would like to knows, if it possible to create in my .html or .php file a link to open another plugin ? Thanks for your help
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
01/20/17 09:27 AM (7 years ago)
If you use the Html Pro plugin, it has this capability.
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/20/17 09:34 AM (7 years ago)
ok no with custom URL ?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
01/20/17 02:20 PM (7 years ago)
Nope - this was the specifically the use case why the Html Pro plugin was developed.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/23/17 01:59 AM (7 years ago)
For android app in BT_customURL near the top underneath public String forceRefresh = ""; add private static final String URL_SCHEME = "my-app:"; then below @Override public boolean shouldOverrideUrlLoading(WebView view, String url){ add if (url.startsWith(URL_SCHEME)) { String screenId = url.substring(URL_SCHEME.length()); loadScreenWithItemId(screenId); return true; } then underneath //remember the URL... currentURL = url; add url = url.replace("file:///android_asset/BT_Docs/", ""); ArrayList<BT_item> allScreens = null; allScreens = *YOURAPPNAMEHERE*_appDelegate.rootApp.getScreens(); for (int i = 0; i < allScreens.size(); i++){ BT_item thisScreen = allScreens.get(i); if (url.contains(thisScreen.getItemId())) { loadScreenObject(null, thisScreen); return true; } } make sure you replace *YOURAPPNAMEHERE* with your apps name then in your .html code <a href="my-app:<yourscreensId>"> if you change this line ---> loadScreenWithItemId(screenId); to --- > loadScreenWithNickname(screenId); then in your .html code <a href="my-app:<yourscreensNickname>"> Hope this helps if your working on android. Thank You Kristan Halls Immacul8 Apps
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/23/17 02:10 AM (7 years ago)
It's for an iOS app. But I keep your code, I think it will serve me. Thanks ;)
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/23/17 02:29 AM (7 years ago)
ok no props. I will also post code for iOS. give me a few min
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/23/17 03:18 AM (7 years ago)
First find your BT_info.plist and right click on it chose open as source code. Underneath <dict> add the following <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>my-app</string> </array> <key>CFBundleURLName</key> <string>com.<yourappnamehere>.com</string> </dict> </array> <key>LSApplicationQueriesSchemes</key> <array> <string>my-app</string> </array> and make sure you change <yourappnamehere> to the correct thing. Im not 100% if all this was needed but I added it all and it worked so ive left it. then in your _appDelegate.m at the bottom before @end add - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { <yourappname>_appDelegate *appDelegate = (<yourappname>_appDelegate *) [[UIApplication sharedApplication] delegate]; [BT_debugger showIt:self theMessage:@"Tapped on a custom URL"]; // Check if we got a screen nickname from the URL to process NSString *loadScreenNickname = [url host]; BT_item *screenObjectToLoad = nil; if ( [loadScreenNickname length] > 1 ) { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"Nickname of screen to load: %@", loadScreenNickname]]; screenObjectToLoad = [appDelegate.rootApp getScreenDataByNickname:loadScreenNickname]; } else { [BT_debugger showIt:self theMessage:@"ScreenNickname to load is blank"]; return NO; } // Check if the Screen was found within the App's JSON data if ( screenObjectToLoad != nil ) { NSLog(@"loading screen:%@", screenObjectToLoad.itemId); [self.getViewController handleTapToLoadScreen:screenObjectToLoad theMenuItemData:nil]; } else { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"URL Scheme error: %@", url]]; } return YES; } make sure you change all instances off <yourappname> then in BT_screen_customURL.m scroll down to [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"shouldStartLoadWithRequest: SCHEME: %@", urlScheme]]; underneath add if ([[url scheme] hasPrefix:@"my-app"]) { UIApplication *app = [UIApplication sharedApplication]; [app openURL:url]; return NO; } else { NSURLRequest *nsrequest=[NSURLRequest requestWithURL:url]; } then in your html use <a href="my-app://yourpluginnamehere"> Hopefully thats it. Let me know if all goes ok Thank You Kristan Halls Immacul8 Apps
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/23/17 03:56 AM (7 years ago)
ok great thanks you for your help, I test it when I've 5 minutes. I will come back to keep you informed when I have tested it ;) Thanks
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/24/17 02:05 AM (7 years ago)
Hi, i've an error on this line : nameapp_appDelegate *appDelegate = (nameapp_appDelegate *) [[UIApplication sharedApplication] delegate]; Missing '[' at start of message send expression And on this line : screenObjectToLoad = [appDelegate.rootApp getScreenDataByNickname:loadScreenNickname]; Expected expression Can you help me please ? PS : I also added the information in the info.plist thanks
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/24/17 02:39 AM (7 years ago)
What version of Xcode are you using? What is your build target version? When you click the error does it have the option to 'fix' ? if so select this. But the code shouldn't have an error. Maybe during copy paste the symbols have changed. You can try deleting and retyping the '=" symbols and also retype the '[' & ']' symbols. Even the '{' '}' symbols. First you could also click editor > show invisibles and make sure theres no weird characters in the code like spaces " " or "^" where they shouldn't be. If you still have these errors please paste the entire code you have entered thx.
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/24/17 03:04 AM (7 years ago)
My version of Xcode is 8.1 and my build target is 8.0. When I click on error, Xcode want add '[' or ']' in differents parts of line. But finally, the line remains in error. This is my code in my appDelegate.m : - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { testqrcode_appDelegate *appDelegate = (testqrcode_appDelegate *)[[UIApplication sharedApplication] delegate]; [BT_debugger showIt:self theMessage:@"Tapped on a custom URL"]; NSString *loadScreenNickname = [url host]; BT_item *screenObjectToLoad = nil; if ( [loadScreenNickname length] > 1 ) { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"Nickname of screen to load: %@", loadScreenNickname]]; screenObjectToLoad = [appDelegate.rootApp getScreenDataByNickname:loadScreenNickname]; } else { [BT_debugger showIt:self theMessage:@"ScreenNickname to load is blank"]; return NO; } // Check if the Screen was found within the App's JSON data if ( screenObjectToLoad != nil ) { NSLog(@"loading screen:%@", screenObjectToLoad.itemId); [self.getViewController handleTapToLoadScreen:screenObjectToLoad theMenuItemData:nil]; } else { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"URL Scheme error: %@", url]]; } return YES; } Thanks for your help
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/24/17 04:12 AM (7 years ago)
are you using the new buzztouch build v4? I am yet to build an app using v4 but I have downloaded a test project and I have now noticed they now set appDelegate global reference //global appDelegate reference... #define appDelegate ((appname_appDelegate *)[UIApplication sharedApplication].delegate) so all you should have to do is remove this line testqrcode_appDelegate *appDelegate = (testqrcode_appDelegate *)[[UIApplication sharedApplication] delegate]; its just conflicting code. Hope this helps Thank You Kristan Halls Immacul8 Apps
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
01/24/17 04:32 AM (7 years ago)
chris1 i have html pro installed and when compiling for iOS theres only a text file with This plugin package does not have a /source-ios-4.0 directory. Contact the plugin developer and ask them to update this plugin package. Do i need to re-purchase it in order for it to work? thx
 
Bertrand
Apple Fan
Profile
Posts: 163
Reg: Dec 26, 2012
saint-quentin f...
4,680
like
01/24/17 07:08 AM (7 years ago)
@immacul8 yes I use V4. Ok thanks I'll test it ;)
 

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.