iOS 15 message extension is not called

369 Views Asked by At

I'm trying to develop a message filtering extension for iOS. My steps as follows:

  1. Create a new project.
  2. Go to File -> Target -> Add Message Filter App Extension, enter a name MyMessageFiltering. Xcode generate the folder MyMessageFiltering contains MessageFilterExtension.swift
  3. In the MessageFilterExtension.swift, add one line after the handle function as follow:
    func handle(_ queryRequest: ILMessageFilterQueryRequest, context: ILMessageFilterExtensionContext, completion: @escaping (ILMessageFilterQueryResponse) -> Void) {
        // First, check whether to filter using offline data (if possible).
        NSLog("FILTEREXTENSION - handle")
  1. Run the app
  2. Enable the app in message extension on iPhone by Settings -> Message -> Unknown & spam
  3. Start the console app and record the phone.
  4. Send a sms message to iPhone by an unknown number.

There is no log from the console app or XCode console

What steps did I do wrong to test the sms extension filtering ?

1

There are 1 best solutions below

0
Tyson On

It is pretty late to answer this question also you might have figured it out already but it is for somebody out there facing the same problem

Actually the steps you have followed to create a message-extension is correct, however assuming from the steps you have followed you're only running the application's target (in your case step 4) there should one more step in-between step 4 and step 5 and that extra step would be as follows :-

  • You need to run your extension's target (in your case MyMessageFiltering) and a dialog will open asking you to run your extension in iPhone's Messages App, select Run in it.

As our extension is of type message-filter extension it is perfectly fine to run in Messages App and then can receive all callbacks when the sms arrives in your iPhone and hence you will also be able to see your log.

Please take a look at the images i'm attaching in a sequential manner.

MyMessageFiltering extension

Need to run your extension in iPhone's Messages app