アプリがバックグラウンドでも次の機能を使いたいですか?
- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent
{
case NSStreamEventHasBytesAvailable:
{ NSLog(@"Event:NSStreamEventHasBytesAvailable");
if (theStream == _inputStream) {
NSLog(@"NSStreamEventHasBytesAvailable: on Input Stream");
uint8_t buffer[1024];
int len;
while ([_inputStream hasBytesAvailable]) {
len = [_inputStream read:buffer maxLength:sizeof(buffer)];
if (len > 0) {
NSString *output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];
if (nil != output) {
NSLog(@"server said: %@", output);
// to get local notification I am calling below method.
[self scheduleNotification];
}
}
}
}
break;
}
上記のコードはforeGroundで実行されています。アップルのドキュメントに記載されているすべての変更を行って、アプリをバックグラウンドモードで実行しました-voip。AppDelegateメソッドで何を書く必要がありますか?
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
バックグラウンドで呼び出されるstream:handleEventを取得する方法は?