How to reconnect the socket from the background to the foreground on iOS

Updated on technology 2024-03-13
5 answers
  1. Anonymous users2024-02-06

    After a few years of iOS development, there is really no better time to recommend that you add a gesture to unlock the page about the 5min limit, you can put a timestamp in the applicationdidenterbackground method, and then judge the time next time you go to the foreground.

  2. Anonymous users2024-02-05

    Put accept() outside of while(), and then create two threads inside while(), send and recv. If you make a mistake, you should only create two threads in the main function, while(1) is put in the thread, and send and recv are put in while(1).

  3. Anonymous users2024-02-04

    1. A VoIP application needs to have the following requirements:

    1. Add the UIbackgroundModes key and set the value to VOIP;

    3. Before the app is switched to the background, you need to call the setkeepalivetimeout:handler: method to register a handler that executes periodically to keep the app connected to the server;

    4. Configure an audio session.

    2. The VoIP value of the UIbackgroundModes key has three functions:

    3. Configure the keep-alive handler

    A VoIP app needs to be woken up periodically to prevent losing connection to the server. To achieve this, the iOS system allows us to use SetKeepAliveTimeOut:Handler:

    methods to achieve the keep-alive. Usually we need to implement the keepalive method after the software is cut to the background, that is, in applicationdidenterbackground:.

    After the Handler is configured, the system will wake up the app in the suspended state before the time out time expires as needed, and the methods in the Handler will be called at least once.

    1、 handler

    It should be noted that this handler needs to be returned as quickly as possible when executed in the background, because the system only gives a maximum of 10 seconds to execute it. If the execution is not completed within 10 seconds, and there is no additional execution time, the system will suspend the app.

    2、timeout

    When you set a handler, you need to specify the maximum timeout period required by the app. The minimum value allowed by the iOS system is 600s, and if you want to set a small dot value, the Handler setting will fail. When the system executes the handler content, it only guarantees that the timeout time will be executed before the timeout, but does not guarantee the accurate execution time, and the system will determine a suitable time point according to the system conditions such as the task situation at that time, which has achieved the purpose of extending the battery life.

  4. Anonymous users2024-02-03

    The external access interface provided by the server side of iOS. You can't use a session session to save a user's login state like web server development. Therefore, for the security of interface access, do some security authentication on the server side before requesting the interface to return data.

    There are some solutions, such as using or customizing some access policies, some as you said using tokens, and some are to send the user's information to the server through the request header httpheader when making a request. It's okay to do it all ways.

  5. Anonymous users2024-02-02

    Provider refers to the push server of an iPhone software, APNS is the abbreviation of Apple Push Notification Service, which is Apple's server.

    The diagram above can be divided into three phases:

    Stage 1: The application packages the message to be sent and the identity of the destination iPhone and sends it to APNS.

    Stage 2: APNS looks for the iPhone with the corresponding logo in its own list of iPhones that have registered for the Push service, and sends a message to the iPhone.

    Stage 3: The iPhone delivers the message to the corresponding application, and pops up a push notification according to the setting.

Related questions
17 answers2024-03-13

Hello. Hope it helps.

It depends on the situation, it should be a group tour, right? >>>More

16 answers2024-03-13

According to your description, Samsung Android phones support the installation and use of third-party software in Android version (APK) format. >>>More

41 answers2024-03-13

The object vibrates in simple harmonics.

Let the mass of the object be m, the mass of the earth be m, the relative distance between the object and the center of mass of the earth be r, the radius of the earth be r, and the average density of the earth be . >>>More

5 answers2024-03-13

Wheat is still used very frequently in daily life, because it can be used to make a variety of pasta. However, there is a big difference between imported wheat flour and domestic wheat flour, first of all, the quality, there are many varieties of wheat in China, it can be said that there are many varieties in a province and city, so it can be freely chosen by everyone, and it is difficult to distinguish between good and bad. The other is that in the international market, China's wheat is higher than that of any country, so the wheat in its own country is the best. >>>More

34 answers2024-03-13

Decision-makers should re-plan or it will be really cold.