0

I've an iOS app with a Tab Bar Controller and five ViewControllers written in Objective-C. Now, I declared QuickActions in Info.plist file.

But cause I'm new at coding and there are only Swift codes to find in the internet I don't know how to do it.

Can anyone provide the code snippet for AppDelegate.m in Objective-C to open an specific ViewController?

Thank you for help!

Greetings, David.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

2

if your application is launched fresh...then its launchOptions will contain shortcut item pressed which you can access using key UIApplicationLaunchOptionsShortcutItemKey.Find the type UIApplicationShortcutItem to perform action accordingly.

If your application is in background and your user selected shortcut item

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler

will be called.As you can see you get pressed shortcut item directly you can get type of pressed item and perform action accordingly.Hope it helps :)

Edit You can check out https://github.com/dakeshi/3D_Touch_HomeQuickAction this will help you alot only difference is he has used dynamic quick actions.And one note about quick actions (both dynamic and static) is that unless you launch your app at least once quick options won't show up on 3D touch.

Sanman
  • 1,158
  • 11
  • 23
  • Thank you for trying to help me. But, my problem is I need the full code in Objective-C. I'm to inexperienced yet to write the code myself. –  May 22 '16 at 10:06
  • Thank you. I'll try it and report. What do you mean with this sentence: "[…]unless you launch your app at least once quick options won't show up on 3D touch" –  May 22 '16 at 10:49
  • i.e before you try quick actions you should have launched app at least once.follow these steps... launch app then press home button so that app goes to background and then try quick actions...hope it helps :) – Sanman May 22 '16 at 10:57
  • Okay, I managed to get I work now without error messages, but there's an other problem. The ViewControllers are opening directly without using the Tab Bar Controller. That means there're no Tab Bar Buttons I can click to change the View. So, this way doesn't work for me. Do you have an other idea/code sample? –  May 22 '16 at 11:50
  • Hey, sorry for my late answer. No, I don't use Storyboard. I'm using Tab Bar Controller and ViewController's. Why are you asking? Do you have an idea? I'm actually trying to convert my app to Swift. Thank would make it easier because there are many manuals for in with Swift in the internet. –  May 23 '16 at 19:17
  • i suggest you learn basics of tabbar controller first...it will help you solve your problem... – Sanman May 24 '16 at 04:16
  • Of cause I use Storyboard. –  May 26 '16 at 12:20