The app I'm developing has an issue with NumberFormatter. When trying to get a NSNumber from String on the iOS 13 (while the app is built with iOS SDK 12), the NumberFormatter returns nil.

When the app is compiled with the iOS SDK 13, the problem disappears. Also, no problem when using iOS SDK 12 and running the app on iOS 12.

How can I debug the app compiled with iOS SDK 12 which runs on iOS 13?

When I trying to do so, the Xcode gives an error that I cannot run the app on the newer iOS with the older version of the SDK.

public let currencyFormatter: NumberFormatter = {
    let f = NumberFormatter()
    f.allowsFloats = true
    f.numberStyle = .currency
    f.locale = Locale.autoupdatingCurrent
    f.currencySymbol = ""
    f.maximumFractionDigits = 2
    f.minimumFractionDigits = 2
    return f
}()

Then, using the formatter:

        let price = "0"
        guard let numberPrice = currencyFormatter.number(from: price) else {
            isValid = false
            break
        }

The else statement gets executed, i.e. currencyFormatter returns nil.

I am trying to implement push notification in ionic version 1 using "AWS SNS" and "Firebase"(for registering my ios and android application) and "phonegap-plugin-push" in ios,by using this plugin i got the token ,but using that token in aws to create endpoint to send the notification to my ios device ,unable to receive the notification,Kindly suggest any thrid party cordova plugin below the version of cordova-ios@4.4.0.

Note: 1.development certificate for ios for push notification are everything submitted.

As soon as end point created using fcm token(which is generated in ios device) in aws sns,end point getting disabled after the first push notification sent.

This is an old source code that I need to optimize. I ran into a problem that secureTextEntry doesn't display properly (See picture). SecureText is enabled through storyboard and there is nothing to do with ViewController.

enter image description here

I want to add a referer to all the resource requests from WKWebview, such as image and video elements, WebViews send those requests for me.

I have already known how to hook the requests, use WKBrowsingContextController registerSchemeForCustomProtocol: NSURLProtocol-WebKitSupport to intercept the request, then add a referer to the request.

But there are several webviews, I need to make a referer with webview, for example:

`NSString *referer = [NSString stringWithFormat:@"https://example.com/%@/232/page-frame.html", @"webView1"];

It's dynamic.

static NSString* const FilteredKey = @"FilteredKey";

@implementation MyURLProtocol

+ (BOOL)canInitWithRequest:(NSURLRequest *)request {
    return [NSURLProtocol propertyForKey:FilteredKey inRequest:request] == nil;
}

+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request {
    NSMutableURLRequest *mutableReqeust = [request mutableCopy];
    [mutableReqeust setValue:@"https://example.com/something/232/page-frame.html" forHTTPHeaderField:@"Referer"];
    return [request copy];
}

- (void)startLoading {
    // ...
}

- (void)stopLoading {
    // ...
}

@end

So my problem is: How can I know the request is from which webview?

i have this function called sendRequest in a class called A and this sendRequest function returns a Any object and in first line i created a variable like this var serverResponse = JSON() and i have this code to request

upload.uploadProgress(closure: { (Progress) in
                })
       upload.responseJSON { response in

       print(response.response?.statusCode as Any)

       if(response.result.isSuccess){
            serverResponse = JSON(response.result.value!)
            print("Success\(serverResponse)")

       }else{
            serverResponse = JSON(response.result.value!)
            print("No Success\(serverResponse)")
       }
  }

the above code is inside the sendRequest function and at the end/outside of this closure i have a return statement returning the server response return serverResponse

and i am accessing this function from class B i created an object of class A now i have this code in class B

var response: Any =  request.sendRequest("url", parameters: body, headers: [:])

now the problem is the response variable here will always have an empty JSON object and i think thats because in the closure the api call is being processed in the background so before the result comes from the server the return statement gets executed giving me an empty JSON object on class B

and i tried returning the serverResponse in the if statement where i checked if its successful or not and gives me an error like this:

Unexpected non-void return value in void function

so how can i solve this problem?

I have fire alarm application. During app is terminated state, a remote push notification with a custom sound is receieved, the app will play the sound. After some time the alarm clearing notification received. I need to stop the custom sound during the second ntoification. Also if the second notification didn't arrive, i need to repeat the sound. The audio which i saved in bundle has 22 sec length. Please respond if anyone have this issue?

I am setting up text fields with Datepicker and Normal Picker but getting error for the same , I am unable to do it. below is the code

class SetupViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {




    @IBOutlet weak var genderPickerInput: UITextField!

    @IBOutlet weak var datePickerInput: UITextField!
    private var datepicker: UIDatePicker?
    var genderPickerData: [String] = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()
        let genderPicker = UIPickerView()
        genderPickerInput.inputView = genderPicker
        genderPicker.delegate = self
        datepicker = UIDatePicker()
        datepicker?.datePickerMode = .date
        datepicker?.addTarget(self, action: #selector(ViewController.dateChanged(datepicker)), for: .valueChanged)

        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.viewTapped(UITapGestureRecognizer)))
        view.addGestureRecognizer(tapGesture)

        datePickerInput.inputView = datepicker


        genderPickerData = ["Male", "Female", "Other"]
        // Do any additional setup after loading the view.
    }

    // MARK: UIPickerView Delegation

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView( _ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return genderPickerData.count
    }

    func pickerView( _ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return genderPickerData[row]
    }

    func pickerView( pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        genderPickerInput.text = genderPickerData[row]
    }
    func dateChanged(datepicker : UIDatePicker){
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "MM/dd/yyyy"
        datePickerInput.text = dateFormatter.string(from: datepicker.date)
        view.endEditing(true)

    }


    func viewTapped(gestureRecognizer: UITapGestureRecognizer){
        view.endEditing(true)



    }
    }

Error 1 : Type 'ViewController' has no member 'dateChanged'

Error 2 : Type 'ViewController' has no member 'viewTapped', did you mean 'viewLoaded'

I have iOS app. How can I record voice when app is closed? If anybody knows then give me a hint.

NSString is storing the value is long(165). If I'm comparing two strings, the compiler doesn't perform the task which is inside the condition even condition is correct. One string is storing long(165) and another one is 165.

if ([_country_id isEqualToString:_countryId]) {
    _countryTF.text=[NSString stringWithFormat:@"%@",[arr valueForKey:@"countryName"]];
    _countryCancelStr=[NSString stringWithFormat:@"%@",[arr valueForKey:@"countryName"]];   
} 

If I'll declare that long(165) as NSNumber, it starts showing an error.

I want to redirect to particular screen once user tap the push notification. and for that i have tried below code and the view presented successfully but i'm unable to use the app navigation flow after setting the particular view as RootViewController.

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    //let alertMsg = (userInfo["aps"] as! NSDictionary)["alert"] as! NSDictionary
    //let payload = userInfo["sendbird"] as! NSDictionary

    //APS DATA
    if let apsData = userInfo["aps"] as? Dictionary<String, Any> {
        print(apsData)
    }

    //USER DATA
    if let userData = userInfo["user_details"] as? Dictionary<String, Any> {
        print(userData)
    }

    //NOTIFICATION DATA
    if let notificationData = userInfo["notification_details"] as? Dictionary<String, Any> {
        print(notificationData)

        let nNotificationType   = notificationData["notification_type"] as! Int
        let nNotificationID     = notificationData["notification_id"] as! Int
    }


    let storyBoard : UIStoryboard = UIStoryboard(name: "Group", bundle:nil)

    if Device.IS_IPHONE_X {
        let controller = storyBoard.instantiateViewController(withIdentifier: "GroupInfoViewController_iPhoneX") as! GroupInfoViewController
                let navController = UINavigationController.init(rootViewController: controller)
    }
    else {
        let controller = storyBoard.instantiateViewController(withIdentifier: "GroupInfoViewController_iPhone8") as! GroupInfoViewController
                let navController = UINavigationController.init(rootViewController: controller)
    }

    // Your custom way to parse data
    completionHandler(UIBackgroundFetchResult.newData)
}

Please guide me how can i use the normal app navigation after move to particular ViewController on notification tap. same like android app.

Please guide me

I want to update the description of the app plus the screenshots on Apple Store but the app remains the same viz same version number(I don't want to publish new app since nothing in the app is changed)

Is that possible or will Apple store ask for app to be updated as well?

I am using FontAwesome.swift in Swift 5 to add a fontawesome icon to my UIbutton. I want to mix fontawesome icon with a String, "Database". Here is what I have tried:

self.titleLabel?.font = UIFont.fontAwesome(ofSize: 15, style: .solid)
self.setTitle(String.fontAwesomeIcon(name: .database) + " Database", for: UIControl.State.normal)

However, the result gives me two identical icons:

enter image description here

What I want is something like this:

ui

An UISplitViewController is created through the storyboard.

I would like to pass data to the detail view, when interacting with the master view, without reinitialize it every time the segue is called.

However when the segue is called, a new detail view controller is initialized and added. It looks like this is default behaviour. How to prevent this?

I used pinch gesture for zooming. It's working fine. Using slider I am rotating that image. Rotation is also working perfect. The problem after zooming, if I rotate the image, the zoom effect is missing. Here is the code I used for rotation

subView.transform = CGAffineTransformMakeRotation(slider.value * 2*M_PI / slider.maximumValue);

Thanks in Advance.

I am getting error while changing format of date. Date that I'm getting from server is of this type : 2019-08-20T08:05:15.680Z.

let dateFormatter: DateFormatter = DateFormatter()

    dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
                    *if let dateFromTimeStamp: Date = dateFormatter.date(from: self.sendMoneyResponseObject.timeStamp!){*
                        dateFormatter.dateFormat = "dd MMM yyyy, hh:mm a"
                        if let dateString: String = dateFormatter.string(from: dateFromTimeStamp) as? String{
                            transactionViewObj.dateLabel.text = dateString
                        }
                    }

Date Format that is needed : dd MMM yyyy, HH:mm a

Is it possible to feature toggle WatchKit? I know I can disable the target by removing it in Build Phases. But I would like to enable WatchKit only for a specific scheme. Building for e.g. production should not bundle the WatchKit app with iOS while building for development should. Can this be achieved?

So basically I converted a older project from swift 2 to swift 4.0, now using Xcode 10.2. One of my VC's is getting crashed randomly.... seems like it has something to do with this object powerDeviceInfos as it crashes randomly on many places in the VC on this object (EXC bad instruction or EXC bad access)

powerDeviceInfos: Dictionary<Device, Dictionary<String, AnyObject>>?

Also it seems like it is connected ... I get crashes on this line

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, Configuring, Identifiable {

The crash says

NSInvalidArgumentException', reason: '-[__NSTaggedDate count]: unrecognized selector sent to instance 0x8000000000000000''

usually its __NSTaggedDate , but sometimes [NSTaggedPointerString count]

seeing this unresolved problem helped me realize it might be Xcode 10.2 problem as well as it has something to do with that Dictionary object (powerDeviceInfos), i am accessing it throughout class both from main and outside of main thread but I don't see why that should be a problem.

I tried enabling zombies and thread sanitizer in Xcode but no luck.... Any ideas guys ? Thanks!

I'm trying to create custom selection menu but it does not work on a device wit MIUI rom. Devices with Android + MIUI setCustomSelectionActionModeCallback not working.

Long press the edit text area and select text in the EditText to listen the action mode callback. Custom action mode not work.

editText.setCustomSelectionActionModeCallback(new android.view.ActionMode.Callback() {
    @Override
    public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
        Log.d(LOG_TAG, "onCreateActionMode");
        return true;
    }

    @Override
    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
        Log.d(LOG_TAG, "onPrepareActionMode");
        return false;
    }

    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        return false;
    }

    @Override
    public void onDestroyActionMode(ActionMode mode) {

    }
});

I have a raised a complaint on MIUI forum - http://en.miui.com/thread-7072028-1-1.html

Is there any workaround for this problem?

Click here to preview the image

I'm getting the following error.

Unable to copy file to destination:
C:\Users The Greatest.android\avd\Nexus_5_API_26_x86.avd\tmp.webm

Does anyone had the same issue? How to change the default destination?

I'm confused how can I send my video to Ziggeo's web service [https://ziggeo.com/applications]?

"I am not good at English" I built in CameraViewActivity And want to send the video created from CameraViewActivity to the server[https://ziggeo.com/applications]

This is code for create video to External Storage Device. I'm need create Video sent to Ziggeo to web server.

I'm did not use iggeo.startCameraRecorder();

I'm using cvCamera.startRecording(fileToSaveRecording.getPath(), maxDuration); is open camera create video

private boolean prepareRecordingFile() {
    if (fileToSaveRecording == null || !fileToSaveRecording.exists()) {
        fileToSaveRecording = new 
        File(Environment.getExternalStorageDirectory() + "/Download", 
                       "tempRecord.mp4");
        try {
            fileToSaveRecording.getParentFile().mkdirs();
            return fileToSaveRecording.createNewFile();
        } catch (IOException e) {
            Log.e(TAG, e.toString());
            return false;
        }
    } else return true;
}

I would like to thank my friends.

I keep getting this error for my code.

I would like to send a notification using Firebase Cloud Messaging to a single device. I already got the FCM token of the device, but how to set the notification to the device.

How to change the API? and the topic, how to find them?

E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero-length.

E/Volley: [1130] BasicNetwork.performRequest: Unexpected response code 401 for https://fcm.googleapis.com/fcm/send

I will provide the code, please help:

MainActivity.java

public class MainActivity extends AppCompatActivity {
    EditText edtTitle;
    EditText edtMessage;
    final private String FCM_API = "https://fcm.googleapis.com/fcm/send";
    final private String serverKey = "key=" + "Your server key";
    final private String contentType = "application/json";
    final String TAG = "NOTIFICATION TAG";

    String NOTIFICATION_TITLE;
    String NOTIFICATION_MESSAGE;
    String TOPIC;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_emergency);
        edtTitle = findViewById(R.id.edtTitle);
        edtMessage = findViewById(R.id.edtMessage);

        findViewById(R.id.btnSend).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                TOPIC = "/topics/userABC"; //topic has to match what the receiver subscribed to
                NOTIFICATION_TITLE = edtTitle.getText().toString();
                NOTIFICATION_MESSAGE = edtMessage.getText().toString();

                JSONObject notification = new JSONObject();
                JSONObject notifcationBody = new JSONObject();
                try {
                    notifcationBody.put("title", NOTIFICATION_TITLE);
                    notifcationBody.put("message", NOTIFICATION_MESSAGE);

                    notification.put("to", TOPIC);
                    notification.put("data", notifcationBody);
                } catch (JSONException e) {
                    Log.e(TAG, "onCreate: " + e.getMessage() );
                }
                sendNotification(notification);
            }
        });

    }

    private void sendNotification(JSONObject notification) {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(FCM_API, notification,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        Log.i(TAG, "onResponse: " + response.toString());
                        edtTitle.setText("");
                        edtMessage.setText("");
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(Emergency.this, "Request error", Toast.LENGTH_LONG).show();
                        Log.i(TAG, "onErrorResponse: Didn't work");
                    }
                }){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<>();
                params.put("Authorization", serverKey);
                params.put("Content-Type", contentType);
                return params;
            }
        };
        MySingleton.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectRequest);
    }
}

MyFirebaseInstanceId.java

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    private static final String TAG = "mFirebaseIIDService";
    private static final String SUBSCRIBE_TO = "userABC";

    @Override
    public void onTokenRefresh() {
        /*
          This method is invoked whenever the token refreshes
          OPTIONAL: If you want to send messages to this application instance
          or manage this apps subscriptions on the server side,
          you can send this token to your server.
        */
        String token = FirebaseInstanceId.getInstance().getToken();

        // Once the token is generated, subscribe to topic with the userId
        FirebaseMessaging.getInstance().subscribeToTopic(SUBSCRIBE_TO);
        Log.i(TAG, "onTokenRefresh completed with token: " + token);
    }
}

MySingleton.java

public class MySingleton {
    private  static MySingleton instance;
    private RequestQueue requestQueue;
    private Context ctx;

    private MySingleton(Context context) {
        ctx = context;
        requestQueue = getRequestQueue();
    }

    public static synchronized MySingleton getInstance(Context context) {
        if (instance == null) {
            instance = new MySingleton(context);
        }
        return instance;
    }

    public RequestQueue getRequestQueue() {
        if (requestQueue == null) {
            // getApplicationContext() is key, it keeps you from leaking the
            // Activity or BroadcastReceiver if someone passes one in.
            requestQueue = Volley.newRequestQueue(ctx.getApplicationContext());
        }
        return requestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req) {
        getRequestQueue().add(req);
    }
}

MyFirebaseMessagingService

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private final String ADMIN_CHANNEL_ID ="admin_channel";

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        final Intent intent = new Intent(this, Emergency.class);
        NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        int notificationID = new Random().nextInt(3000);

      /*
        Apps targeting SDK 26 or above (Android O) must implement notification channels and add its notifications
        to at least one of them. Therefore, confirm if version is Oreo or higher, then setup notification channel
      */
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            setupChannels(notificationManager);
        }

        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this , 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),
                R.drawable.notify_icon);

        Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, ADMIN_CHANNEL_ID)
                .setSmallIcon(R.drawable.notify_icon)
                .setLargeIcon(largeIcon)
                .setContentTitle(remoteMessage.getData().get("title"))
                .setContentText(remoteMessage.getData().get("message"))
                .setAutoCancel(true)
                .setSound(notificationSoundUri)
                .setContentIntent(pendingIntent);

        //Set notification color to match your app color template
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
            notificationBuilder.setColor(getResources().getColor(R.color.colorPrimaryDark));
        }
        notificationManager.notify(notificationID, notificationBuilder.build());
    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    private void setupChannels(NotificationManager notificationManager){
        CharSequence adminChannelName = "New notification";
        String adminChannelDescription = "Device to devie notification";

        NotificationChannel adminChannel;
        adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
        adminChannel.setDescription(adminChannelDescription);
        adminChannel.enableLights(true);
        adminChannel.setLightColor(Color.RED);
        adminChannel.enableVibration(true);
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(adminChannel);
        }
    }
}