Urban Airship Implementation on iOS

怎甘沉沦 提交于 2019-12-20 07:15:57

问题


I am trying to add libUAirship-1.4.0.a by going to Build Phases > Link Binary With Libraries and locating the library on disk, after doing so i am still getting an error saying use of undeclared identifier: UAirshipTakeOffOptionsLaunchOptionsKey, UAirship, UAPush.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    //Create Airship options dictionary and add the required UIApplication launchOptions
    NSMutableDictionary *takeOffOptions = [NSMutableDictionary dictionary];
    [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];

    // Call takeOff (which creates the UAirship singleton), passing in the launch options so the
    // library can properly record when the app is launched from a push notification. This call is
    // required.
    //
    // Populate AirshipConfig.plist with your app's info from https://go.urbanairship.com
    [UAirship takeOff:takeOffOptions];

    // Set the icon badge to zero on startup (optional)
    [[UAPush shared] resetBadge];

    // Register for remote notfications with the UA Library. This call is required.
    [[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                         UIRemoteNotificationTypeSound |
                                                         UIRemoteNotificationTypeAlert)];

    // Handle any incoming incoming push notifications.
    // This will invoke `handleBackgroundNotification` on your UAPushNotificationDelegate.
    [[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
                       applicationState:application.applicationState];

    return YES;
}

回答1:


You need to #import the header file associated with the library in order for the symbols to be available. For this library I believe you want to add the following to the top of your source file:

#import "UAirship.h"
#import "UAPush.h"



回答2:


I have seen many different variations of how to set the Header Search Paths. For me, this worked. Airship folder is in same level as the project.

$(PROJECT_DIR)/Airship


来源:https://stackoverflow.com/questions/15131933/urban-airship-implementation-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!