2016-05-07 4 views
0

私は知らないこの質問をするのが適切な場所であるかどうか。しかし、私は非常に少ないのiOS知識と私の周りにいない熟練のiOS DEVを持っているので、誰かがこれを答えるならば...私はとても幸せになります。..iOSアプリでユーザーのカスタム通知を設定することは可能ですか?

は、iOSローカル通知のための

ユーザーのカスタム通知を設定することが可能であろう?

のように、彼は通知をどのくらい多くの時間を受け取るかを選択します そして、彼はそれを望んでいますか?

答えて

0

もちろん可能です。これは、ユーザー設定をNSUserDefaultsに保存していることを前提にしても、2つの方法で行うことができます。

方法1;通知がトリガーされることを期待しない限り、位置情報サービスを開始しないでください。

func prepareForLocationServices { 
    if (NSUserDefaults.standardUserDefaults().boolForKey("userWantsNotifications")) { 
     // enable your location services and register for any local notifications you want 
    } 
    else { 
     // maybe enable some ui mentioning the feature, and allowing the user to go to your settings view controller to enable or disable notifications 
    } 
} 

方法2:常にロケーションサービスを開始し、場所が更新されるたび、彼に通知を表示する前にユーザー設定を確認してください。

func locationManager(_: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    if (NSUserDefaults.standardUserDefaults().boolForKey("userWantsNotifications")) { 
     // send a local notifications 
    } 
    else { 
     // do nothing, since the location update is probably triggered in the background 
    } 
} 

実際にローカル通知を作成する方法については、こちらのドキュメントを参照してください。 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/doc/uid/TP40006728-CH3-SW86

関連する問題