【发布时间】:2014-03-17 10:30:19
【问题描述】:
我正在使用 UrbanAirship 来管理我的 iOS 应用程序中的通知。
我想添加一些关于如何管理通知的特定行为,因此我决定在自定义处理程序上实现协议UAPushNotificationDelegate。
在这个协议中,我只是在这两个函数中添加了一些用于测试目的的 NSLog。
- (void)displayNotificationAlert:(NSString *)alertMessage{
NSLog(@"Foreground Alert");
}
- (void)launchedFromNotification:(NSDictionary *)notification{
....Here I added code to present an alert view...
}
然后在 AppDelegate 方法 didFinishLaunchingWithOptions 我添加了 UrbanAirship 配置:
// UrbanAirship data
UAConfig *config = [UAConfig defaultConfig];
[UAirship takeOff:config];
// THE DELEGATE!
UANotificationDelegate *pushDelegate = [[UANotificationDelegate alloc]init];
[UAPush shared].pushNotificationDelegate = pushDelegate;
[UAPush shared].notificationTypes = (UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert );
这是我用来测试代码的测试 curl 调用。
curl -X POST -u "_APPKEY_:_MASTERKEY_" \
-H "Content-Type: application/json" \
--data '{"device_tokens": ["_THETOKEN_"],
"aps": {"alert": "Hello!"}}' \
https://go.urbanairship.com/api/push/
我的设备收到通知,但我的自定义方法永远不会被调用。 我做错了什么?
【问题讨论】:
标签: ios urbanairship.com