title: AFNetworking Background Session Configuration for iOS 8 Extension
body: <p>I'm currently developing an iOS 8 App Extension, and am having difficulty with this one last piece. In the rest of my app, I use an AFHTTPSessionManager subclass that I instantiate like this:</p>
  
  <pre><code>+ (MYAPIClient *)sharedClient {
      static MYAPIClient *_sharedClient = nil;
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^{
          _sharedClient = [[MYAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kMYBaseURL]];
          _sharedClient.requestSerializer = [[MYAPIRequestSerializer alloc] init];
          _sharedClient.responseSerializer = [[MYAPIResponseSerializer alloc] init];
      });
      return _sharedClient;
  }
  </code></pre>
  
  <p>When I just used this regular API client, just posting some text form a share extension worked fine, and it even works for images sometimes (usually fails though), but I know that I need to be using a background session configuration. So I made a very similar api client with a background configuration setup like this:</p>
  
  <pre><code>+ (MYAPIClient *)sharedBackgroundClient {
      static MYAPIClient *_sharedClient = nil;
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^{
  
          NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"com.me.myapp.backgroundconfiguration"];
          _sharedClient = [[MYAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kMYBaseURL] sessionConfiguration:sessionConfiguration];
          _sharedClient.requestSerializer = [[MYAPIRequestSerializer alloc] init];
          _sharedClient.responseSerializer = [[MYAPIResponseSerializer alloc] init];
      });
      return _sharedClient;
  }
  </code></pre>
  
  <p>The problem is, when I make my POST using this client, I get these erros every single time.</p>
  
  <pre><code>Aug 21 19:19:07 MY-iPhone Share[6290] &lt;Notice&gt;: Attempted to create a task in a session that has been invalidated
  Aug 21 19:19:07 MY-iPhone Share[6290] &lt;Warning&gt;: *** Assertion failure in -[MYAPIClient setDelegate:forTask:], /Users/me/Documents/myproject/myproduct/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m:337
  Aug 21 19:19:07 MY-iPhone Share[6290] &lt;Error&gt;: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: task' 
  </code></pre>
  
  <p>Any advice on how to get this to work? Thanks a lot. </p>