-3
//
//  AppDelegate.m
//

#import "AppDelegate.h"
#import "MainViewController.h"
#import "SetupViewController.h"

#import <Cordova/CDVPlugin.h>

#import "NSObject+Utils.h"
#import "WebProjectSetupHelper.h"
#import "WebProjectSetupHelperDelegate.h"
#import "LoadingView.h"

#import "AppDelegate.h"
#import "MainViewController.h"
#import "NSObject+Utils.h"

#import "DeviceModelInfo.h"
#import "UIDevice+System.h"
#import "Alert.h"

@interface AppDelegate () <WebProjectSetupHelperDelegate>


@property (nonatomic, strong) WebProjectSetupHelper *helper;
@property (nonatomic, strong) LoadingView *loadingView;

@end

@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [self createItemsWithIcons];

    // determine whether we've launched from a shortcut item or not
    UIApplicationShortcutItem *item = [launchOptions valueForKey:UIApplicationLaunchOptionsShortcutItemKey];
    if (item) {
        NSLog(@"We've launched from shortcut item: %@", item.localizedTitle);
    } else {
        NSLog(@"We've launched properly.");
    }

    return YES;
}

I am using this code in my App Delegate but on the line that contains "[self createItemsWithIcons];", I get an error that says "No visible @interface for 'AppDelegate' declares the selector 'createItemsWithIcons'".

Any idea what I am doing wrong? I am trying to add quick actions with 3D touch to my app.


Update! I got that issue resolved. Now my next question is from my AppDelegate, how can I run code that is in different file? In the "www" folder there is a file that ends in .js. In that file, there is javascript code that I want to run. Any Ideas on how to call that file?

1 Answers1

0

You have missed to add implementation for createItemsWithIcons method.

https://github.com/versluis/3D-Touch/blob/master/3D%20Touch/AppDelegate.m

If you are working with 3D-Touch sample, then add this code to AppDelegate:

- (void)createItemsWithIcons {

    // create some system icons (doesn't work)
//    UIApplicationShortcutIcon *loveIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeLove];
//    UIApplicationShortcutIcon *mailIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeMail];
//    UIApplicationShortcutIcon *prohibitIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeProhibit];

    // icons with my own images
    UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"iCon1"];
    UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"iCon2"];
    UIApplicationShortcutIcon *icon3 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"iCon3"];

    // create several (dynamic) shortcut items
    UIMutableApplicationShortcutItem *item1 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.test.dynamic" localizedTitle:@"Dynamic Shortcut" localizedSubtitle:@"available after first launch" icon:icon1 userInfo:nil];
    UIMutableApplicationShortcutItem *item2 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.test.deep1" localizedTitle:@"Deep Link 1" localizedSubtitle:@"Launch Nav Controller" icon:icon2 userInfo:nil];
    UIMutableApplicationShortcutItem *item3 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.test.deep2" localizedTitle:@"Deep Link 2" localizedSubtitle:@"Launch 2nd Level" icon:icon3 userInfo:nil];

    // add all items to an array
    NSArray *items = @[item1, item2, item3];

    // add this array to the potentially existing static UIApplicationShortcutItems
    NSArray *existingItems = [UIApplication sharedApplication].shortcutItems;
    NSArray *updatedItems = [existingItems arrayByAddingObjectsFromArray:items];
    [UIApplication sharedApplication].shortcutItems = updatedItems;

}
Evgeny Karkan
  • 8,782
  • 2
  • 32
  • 38
  • I'm sorry but how should I do that? – Ellen Schlechter Apr 27 '16 at 22:13
  • Copy and paste code snippet inside AppDelegate.m file. – Evgeny Karkan Apr 27 '16 at 22:15
  • Thank you for a response. After doing that, more issues came up. I am not using my own images and do not have any dynamic buttons, only static. So really all I would need is the last group of code and the first line right? Commenting out everything else causes an error is the second line of the last group of code. – Ellen Schlechter Apr 27 '16 at 22:26
  • No, it is not enough for you, because `items` depends on `item1`, `item2`, `item3`, which depends on image icons. Try to find 3 small icons, replace with them icons from the code snippet, build and run you app to see what happens and how it can be improved for your needs. – Evgeny Karkan Apr 27 '16 at 22:39