【发布时间】:2016-07-05 12:20:30
【问题描述】:
我正在使用 UrbanAirship 在我的 iOS 应用中处理推送通知。我想实现 UAPushNotificationDelegate 。这是我在 appdelegate 中的代码。
//Appdelegate.m
UAConfig *config = [UAConfig defaultConfig];
[UAirship takeOff:config];
[[UAirship push] updateRegistration];
[UAirship push].userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
[UAirship push].autobadgeEnabled = YES;
[UAirship push].userPushNotificationsEnabled = YES;
PushHandler *pushHandlerDelegate = [[PushHandler alloc] init];
[UAirship push].pushNotificationDelegate = pushHandlerDelegate;
这是我的 PushHandler.h 文件
// PushHandler.h
@interface PushHandler : NSObject<UAPushNotificationDelegate>
@end
然后我在我的实现文件中实现了 UrbanAirship 方法
- (void)receivedForegroundNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Call the completion handler
completionHandler(UIBackgroundFetchResultNoData);
}
- (void)launchedFromNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
// Call the completion handler
completionHandler(UIBackgroundFetchResultNoData);
}
- (void)launchedFromNotification:(NSDictionary *)notification actionIdentifier:(NSString *)identifier completionHandler:(void (^)())completionHandler {
// Call the completion handler
completionHandler()
}
- (void)receivedBackgroundNotification:(NSDictionary *)notification actionIdentifier:(NSString *)identifier completionHandler:(void (^)())completionHandler {
// Call the completion handler
completionHandler()
}
- (void)receivedBackgroundNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Call the completion handler
completionHandler(UIBackgroundFetchResultNoData);
}
但是当我收到 push 时,没有一个函数在调用。我在哪里做错了?
【问题讨论】:
-
嗨。你找到解决办法了吗?
标签: ios objective-c push-notification apple-push-notifications urbanairship.com