Notification Service Extensions with NSLocalizedString - swift

I am using Notification Serivce Extension to change the text coming from the server as per what I Want.
However, that was working good with normal strings. but when I used NSLocalizedString with it, it dosent show the localized string, instead it shows the field name of the string.
For example: inside the UNNotificationServiceExtension:
let CompanyViewLM = NSLocalizedString("Notifications.View", comment: "No Comment")
and in Localizable.strings I put the following line:
Notifications.View = "I Viewed your profile";
Noting that I put the same lines of code in a normal view controller and it works just fine.

I Found by my self what was the problem.
The notification service target was working in the project without recognizing other files of the project.
To make it recognizes other files you must go to targets -> NotificationService -> Copy Bundle Resources -> add the files you want the notification service to work with.
In my case, I added the Localizable.strings file and it worked as a charm.

Related

MobileFirst 7.1 BusyIndicator showing weird characters

I'm developing an hybrid app on MobileFirst 7.1, with Ionic libraries.
In a .js file I globally define
var busyIndicator = new WL.BusyIndicator ("content", {text: "DUMMY TEXT"});
but when I call for it to show, i.e.
busyIndicator.show();
I always get the same message, ignoring the text I put in the text field:
Image link here
I'm testing this on Android devices (Huawei P7 Ascend, Samsung Galaxy J5, both with Android 5.1). On the Android Mobile Simulator the message displays just fine.
p.s. "content" matches my html id, I tried putting null instead of "content" but to no avail.
A workaround
define in some common .js file
function showMyIndicator() {
busyIndicator.__options.text="Custom loading text";
busyIndicator.show();
}
and call showMyIndicator() each time you would call busyIndicator.show().
busyIndicator.hide() can be called normally (although you might want to define some 'hideMyIndicator()' function for homogeneity).
What is happening?
It appears that, as soon as I load (jQuery $.load() ) some new content in order to change page, the text fileld of the busyIndicator object defaults to "[(')ههههههه Loading]", which is defined in every native project inside messages.json.
That file is full of those weird signs, no idea about why.
Update
There's something corrupted in my project which causes those .json files to be generated with wrong characters, a freshly generated project didn't show the same issues so creating a new one and move the resources in there might do the trick.

iPhone Finding AppDelegate

I am trying to create MAC application.
My input is --> Source Code Folder of an existing iPhone Application.
Using my application I want to insert an extra screen in the existing application. The extra screen will be always the first screen.
Since I want to Automate this, I have written a MAC application which browses through the Source code folder and replaces the first screen of app with my extra screen. This is working perfectly for Single View Application where I get the AppDelegate class name from the main.m file ( by parsing UIApplicationMain(argc,argv,MyAppDelegate,nil) ) line.
The application fails when the third argument is 'nil' in some of the applications (which may depend on the implementer or type of project).
Is it possible to make my application generic for all kind of applications?
Regards,
Nirav
Looks like you would only have to search (recursively) the folder for all .h files, and then detect the name of the class that implements UIApplicationDelegate. There should not usually have more than one, and would work with the defaults templates I guess.

How to register a custom app opening URL scheme with Xcode 4?

Xcode4 is asking for a huge number of arguments just to make this simple thing possible:
NSString *stringURL = #"twitterriffic://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
What are all these properties for? Why an image? Must I repeat the app identifier here? What role to choose if I want anyone to be able to call this URL to open my app? And what are these Additional url type properties for?
I found no Xcode4-related tutorial how to register such an URL scheme with Xcode 4.
Open "Supporting Files" (folder) on left and click the "YourAppName-Info.plist"
Choose a row like "Bundle creator OS Type Code" and mouse over row and click the (+) symbol
This creates a new row and type "URL types"
Click the arror to left and see Item 0 and you'll rename the value in Item 0 to "URL Schemes" as shown
Then edit the field in Item 0 and type in your prototocol; I typed in "goomzee" as shown
Now if I install this app on my simulator, and open Safari and type "goomzee://" in the address bar it will launch my app.
Yup, this stuff isn't straightforward is it ?
I've outlined the steps required to register a custom URL here:
Custom URLs
But, basically the key to it is setting up a "URL Types" value in your .plist file. Here's what it looks like in XCode 5:
In this example, I've registered the MKB prefix, so now, I can use this new type of URLs in hyperlinks on webpages, and emails (if I read an email in the iPad Mail app):
If a user taps on one of these links, my iPad app will start up, and I can access the full URL string, to extract the other parameters from the URL (eg "DocumentNumber=100")
The only gotcha is that I have yet to work out how to test whether a user has an iPad app installed which can recognise a particular prefix.
If they haven't, and they tap on one of these MKB:// links on their iPad, they'll get an ugly error message:
You can continue to register your custom URL by editing your app's info.plist file (as shown in one of your previous questions). The new editor in Xcode 4 is supposed to be a convenience to make it easier to add the entries - all it is doing is making the same info.plist changes that you would do manually. If you want to use the new editor then you only need to fill in the 'Identifier' and the 'URL Schemes' boxes. You don't need an image, icon or additional URL properties.
The other properties (icon etc) are not well documented but seem to be applicable only on Mac OS X and might be used in the Finder's Get Info dialog to display what types of URL a particular app can open. For example, take a look at the Launch Services Programming Guide.
What you change in that editor is also reflected in your project's info plist file. It takes the form of ProjectName-Info.plist. Hopefully that helps.

Localized XIB not showing all IBActions, outlet & images

i m getting a problem with my localized xib.
I have created english version xib first, then made them localized, & added other localization.
it works fine in app also.
But when i open other language xib with IB, i m unable to get all outlets & IBActions.
It seems like it is taking only those one that were present when i created the localized file, & not showing newly added one.
Does file not getting updated?
Note : My other team member done the same thing & they don't have problem.
i also tried to removed & created all new localized file then also no change.
I m unable to identify the problem, i m stuck on this problem & cannot proceed with further development.
Please help .. :(
If you have Xibs in different languages, they don't get updated automatically when you change the English one.
Instead, you should either merge the new changes using ibtool (type man ibtool in Terminal to learn its options), or use a dedicated application like iLocalize.
In general, it can be quite an issue to update all the localizations all the time and sometimes large changes can't be merged well automatically. You need to be careful about that.

iPhone Localization: simple project not working

Im doing my first localized project and I've been fighting with it for several hours with no luck.
I have to create an app that, based on the user selection, shows texts and images in different languages.
I've read most of Apple's documents on the matter but I cant make a simple example work.
This are my steps so far:
1) Create a new project.
2) Manually create a "en.lproj" directory in the projects folder.
3) Using TexEdit create file called "Localizable.strings" and store it in Unicode UTF-16. The file looks like this:
/*
Localizable.strings
Multilanguage02
Created by Gonzalo Floria on 5/6/10.
Copyright 2010 __MyCompanyName__. All rights reserved.
*/
"Hello" = "Hi";
"Goodbye" = "Bye";
4) I drag this file to the Resources Folder on XCode and it appear with the "subdir" "en" underneath it (with the dropdown triangle to the left). If I try to see it on XCode it looks all wrong, whit lots of ? symbols, but Im guessing thats because its a UTF-16 file. Right?
5) Now on my view did load I can access this strings like this:
NSString *translated;
translated = NSLocalizedString(#"Hello", #"User greetings");
NSLog(#"Translated text is %#",translated);
My problem is allowing the user to switch language. I have create an es.lproj with the Localizable.strings file (in Spanish), but I CANT access it.
I've tried this line:
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:#"es", nil] forKey:#"AppleLanguages"];
But that only works the NEXT time you load the application. Is there no way to allow the user to switch languages while running the application??
Do I have to implement my own Dictionary files and forget all about NSLocalizableString family?
Thanks for ANY advice or pointers.
Gonso
There is already a discussion about that here.
Their suggestion is to create a sub-bundle and then use a method called NSLocalizedStringFromTableInBundle(...) (as described in the reference manual) to
get a localized string from a specific table in a bundle.
I am just giving you an hunch, I haven't tried but, I guess, this could be a good way to face your problem.