推送通知在ApplePushNotificationAppDelegate.m上運行。iphone - 更改標籤推送通知可能嗎?
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
ApplePushNotificationViewController *apns = [ApplePushNotificationViewController alloc];
NSLog(@"%@ changed", [apns labelchange]);
}
它去ApplePushNotificationViewController.m和做到這一點
-(NSString *)labelchange{
label2.text = @"labelchanged";
return @"hi";
}
,結果在控制檯這是在不改變標籤上我的iPhone
2011-08-03 18:20:56.501 ApplePushNotification[1473:707] key: acme1, value: bar
2011-08-03 18:20:56.503 ApplePushNotification[1473:707] key: acme2, value: 42
2011-08-03 18:20:56.505 ApplePushNotification[1473:707] hi changed
2011-08-03 18:21:04.347 ApplePushNotification[1473:707] key: aps, value: {
alert = "You got a new denyapps!";
badge = 5;
sound = "beep.wav";
}
爲什麼我的程序運行該程序,但不會將label2.text更改爲「labelchanged」?
需要獲得使用推送服務的證書,但這裏是項目的鏈接,「PushMeBaby」是服務器。
http://dl.dropbox.com/u/12439052/ApplePushNotification.zip http://dl.dropbox.com/u/12439052/PushMeBaby.zip
感謝。
如果你已經初始化你LABEL2?它可能不會被初始化,爲什麼它不改變它的文本。 – Mahesh