2016-08-11 5 views
0

私はローカル通知をスケジュールするカスタムボタンを作成しようとしています。私がここで見つけたコードは古くなっているようです。私はアップルからの概要を見てきましたhttps://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html
しかし、私はまだかなり混乱しています。どの人がどのファイルをどのファイルに入れるかなど、きれいで簡潔な例を投稿できますか? (登録を含む)ローカルの通知を作成するだけの例でも役に立ちます。ありがとうございます! AppDelegateでローカル通知付きのカスタムUIButton

NSDate * fireDate; // The schedule date time. 
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
localNotification.fireDate = fireDate; 
localNotification.timeZone = [NSTimeZone defaultTimeZone]; 

localNotification.alertBody = @"alertText"; 
localNotification.alertAction = @"buttonTitle"; 
localNotification.soundName = UILocalNotificationDefaultSoundName; 


// Schedule it with the app 
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

:あなたがこれを行うボタンタップメソッド内AppDelegate.mで

+0

noti薬草?プッシュ通知? –

+0

私は自分の目的のためにローカル通知が必要だと思う。 – DSmith

+0

ローカル通知はどういう意味ですか?スケジュールされた時間にアプリに登場するポップオーバーのように? –

答えて

0

、(後のiOS 8.0からと)ユーザーとの対話の種類のアプリのサポートを登録

UIUserNotificationType types = (UIUserNotificationType) (UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound | UIUserNotificationTypeAlert); 

UIUserNotificationSettings *mySettings = 
      [UIUserNotificationSettings settingsForTypes:types categories:nil]; 

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings]; 

.m(必要に応じて)ローカル通知が届いたときにこのメソッドを追加してください:

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)localNotification{ 
    // This method gets called when a local notification arrives 
}