I have this posted on PhoneGap google groups and cross-posted it here on Stack Overflow.
Anyway, PhoneGap's Contact API is giving me headache lately. To cut it short:
Environment
iOS 6
PhoneGap 2.0.0
I have this application that scans a QR code with VCard embeded, and it will save it into user's contact once the user agree to save it down. On Android 4.1.2, this piece of code works flawlessly without any error, and contact was saved too. On iOS 6, however, I can't get it to work. What I have always receive is error #4, which is, ContactError.IO_ERROR.
The code is as below:
navigator.notification.confirm('Found a contact: "'+(vcard['N'] || '')+'". Add it into your contact list?', function(btn) {
if (btn == 1) {
var contact = navigator.contacts.create();
contact.displayName = vcard['N'] || '';
contact.emails = [new ContactField('email', vcard['EMAIL'] || '')];
var org = new ContactOrganization();
org.name = vcard['ORG'] || '';
contact.organizations = [org];
contact.save(function() {
navigator.notification.alert('Contact Saved');
}, function(err) {
navigator.notification.alert('Error on saving contact: '+err.code);
});
}
}, 'QR Code Scanner', 'OK,Cancel');
And below is the only log I have seen on XCode right after I tap on 'OK': (first callback is for the notification.confirm)
2012-10-22 21:19:24.619 [11897:907] PluginResult:toJSONString - {"status":1,"message":1,"keepCallback":false}
2012-10-22 21:19:24.621 [11897:907] PluginResult toSuccessCallbackString: cordova.callbackSuccess('Notification12',{"status":1,"message":1,"keepCallback":false});
2012-10-22 21:19:24.738 [11897:907] PluginResult:toJSONString - {"status":9,"message":4,"keepCallback":false}
2012-10-22 21:19:24.739 [11897:907] PluginResult toErrorCallbackString: cordova.callbackError('Contacts13',{"status":9,"message":4,"keepCallback":false});
Then I will see the alert:
Error on saving contact: 4
Note
vcard is a key-value pair of vcard obj. Please ignore this for now. It's not important.
This piece of code works fine on android.
Is this the correct way of creating contact? How can you save a contact on iOS 6 using PhoneGap?
Edit
I did all the necessary migration and upgraded to v2.1.0, but the error code still emerges. Why is this?
Edit
Apparently this has something to do with the new AddressBook permissions request on iOS 6 as mentioned by Mark, but no one has answered me on how to do it properly. Spent some times on research I came to a conclusion that it's best if we can just wait for Phonegap to finish up v2.2 as I saw permission request being added in CDVContacts.m in v2.2 rc2 commit 61857860...
https://issues.apache.org/jira/browse/CB-902
Currently crashes if the user does not have AddressBook permission on iOS 6.
The user will get a popup dialog similar to the Geolocation permissions dialog. When creating an address book, we should handle the condition where the app does not have permission, and the address book returned is NULL.
i've had the same problem. As it turns out, i was using phonegap version 1.9, which did not support iOS 6, therefore adding a contact gave me Error 4 message all the time. To fix this, i upgraded to phonegap version 2.1. This version supports iOS 6 as well as both armv6 and armv7 architectures. The error message was because iOS 6 requires permissions to access the address book, in the same way that using the GPS requires permission on iOS. This should solve your problem, it did for me :)
Related
I am developing a Xamarin.Android App to read the incoming call phone number, and I was able to get the same in Android Oreo. But once we upgraded to Android Pie
string telephone = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);
always returns 'null'.
While Searching, I find out that by adding 'READ_CALL_LOG' permission it will work in Android Pie.
I already tried by adding 'READ_CALL_LOG' to AndroidManifest.xml,
Also given the run time permission for 'READ_CALL_LOG' and 'READ_PHONE_STATE'
in my MainActivity.cs
But Nothing worked for me.
Please tell me if I am missing anything?
```in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_CALL_LOG" />
```in MainActivity.cs
if (ContextCompat.CheckSelfPermission(this,
Manifest.Permission.ReadPhoneState) !=
Android.Content.PM.Permission.Granted ||
Manifest.Permission.ReadCallLog) != Android.Content.PM.Permission.Granted)
{
ActivityCompat.RequestPermissions(this,
new string[] { Manifest.Permission.ReadCallLog,
Manifest.Permission.ReadPhoneState },2);
}
in Android 9, you have to explicitly ask for both the READ_PHONE_STATE and the READ_CALL_LOG permissions at run time. In previous Android versions you only had to ask for the READ_PHONE_STATE permission. Both of them have to be asked at run time.
If the receiving app has Manifest.permission.READ_CALL_LOG and
Manifest.permission.READ_PHONE_STATE permission, it will receive the
broadcast twice; one with the EXTRA_INCOMING_NUMBER populated with the
phone number, and another with it blank
Here is the TelephonyManager docoument.
I'm stumped, iOS 11.4 ( 15F79 ), iPhone 6. Cannot get the App to Ask for Motion Data. info.plist has been set via the editor and double checked via the info.plist open in textWrangler, Also deleted key and saved via textWrangler.
<key>NSMotionUsageDescription</key>
<string>This app needs your Phones motion manager to update when the phone is tilted. Please allow this App to use your phones tilt devices</string>
I have deleted then reinstalled the app about 10 times. I have restared the phone 5 times. I have checked through settings and my app does NOT show up in Privacy-Motion and Fitness or anywhere else in settings. I am using a free developer account, maybe that has something to do with it?
I created a new Xcode game template and changed nothing apart from importing CoreMotion and this code
**** Edited, sorry I forgot to say I had started the instance, just forgot to put it here, just in case someone thinks that's the problem ************
let motionManager = CMMotionManager()
override func didMove(to view: SKView) {
motionManager.startDeviceMotionUpdates()
if motionManager.isDeviceMotionActive == true {
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!, withHandler: {
(accelerometerData: CMAccelerometerData!, error: NSError!) in
let acceleration = accelerometerData.acceleration
print(accelerometerData)
} as! CMAccelerometerHandler)
}else{
print(CMMotionActivityManager.authorizationStatus().rawValue)
}
which prints a 0 ( an Enum - case not determined ) to the console.
In my actual app it was a 3 ( same Enum - case Denied ).
As I've said, I have uninstalled, reinstalled, edited plist via Xcode and text wrangler ( a code editor ) , tried different versions of the code above, tried the code in different places ( in did move to view, in class )tried code off apple docs. etc.... I haven't been asked the NSUsage question and the App keeps crashing.
I have looked for ways to get the Alert fired up, As in CLLocationManager.requestWhenInUseAuthorization() but I cannot find a comparable CMMotion version ( I don't think there is one. ) I have created a new swift file , imported Foundation and CMMotion and just put that code there, But still no Alert asking for Motion Data.
I tried a single view app template instead of a game template thinking that might be the issue, Nope.
What do I do?
Any help Appreciated. Thanks
You are confusing two related but different classes.
CMMotionManager gives access to accelerometer, magnetometer and gyroscope data. It does not require any user permission as this information is not considered privacy related.
In your else clause you are checking the authorisation status of CMMotionActivityManager. This object reports the device motion type (walking, running, driving). This information is considered privacy related and when you create an instance of this class and request data from it, the permissions alert is displayed.
The reason your else is being triggered is because you are checking isDeviceMotionActive; this will be false until you call startDeviceMotionUpdates, which you never do. Even if you used isAccelerometerActive you would have a problem because you call startAccelerometerUpdates in the if clause which will never be reached.
You probably meant to check isAccelerometerAvailable. If this returns false then there isn't much you can do; the device doesn't have an accelerometer.
Update
It doesn't make sense to check isDeviceMotionActive immediately after calling startDeviceMotion:
You know it's active; you just started it
I imagine the start up takes some time, so you could expect to get false if you check immediately.
Apple recommends that you do not have more than one observer in place for each motion device type, so the purpose of check the is...Active to ensure you don't call start... again if you have already done so.
If you only want gyroscope data then you don't need to call startDeviceMotionUpdates at all.
When using childByAutoId, something really strange happens. Instead of getting a unique id, I get the following key every time:
-------------------0
I know keys are generated with client side timestamps, so I tried running my code through the iOS simulator and an actual device, same result though.
I don't do anything interesting in my code, but here it is for reference:
func sendRandomMessage() {
let firebaseRootRef = Firebase(url:firebaseRootUrl)
let newMessageRef = firebaseRootRef.childByAutoId()
println(newMessageRef.key)
}
I'm using Firebase 2.3.0
There was a bug in the Firebase SDK for iOS 2.3.0 that caused this problem.
It has been fixed in 2.3.1. See https://www.firebase.com/docs/ios/changelog.html
I've had Facebook integrated in my Unity app, and I've been using it on my iPhone 5 with iOS 7 with no problem. But the problem comes when I try it on my friend's iPhone 6 running iOS 8. When I make a call to FB.Login() it switches to the Facebook app, as it normally should, but when it comes back to my app, Facebook opens the Webview for the Facebook login page with the error "You must log in to continue."
The app registers that Facebook.IsLoggedIn is true, and the app continues as if it's logged in, but the Webview is still there and I have to close it to get back to my app.
The only real clue I have about what could be wrong is that the LoginCallback is being called twice in iOS 8 but not in iOS 7.
Any relevant code is below, but it seems like the issue is coming from within the Facebook SDK itself.
public static readonly string FB_SCOPE = "email,public_profile,user_friends";
FB.Login(FB_SCOPE,FBLoginResult);
void FBLoginResult(FBResult result) {
Debug.Log (result.Text);
}
Anyone have any idea, or experience anything similar?
I had the exact same problem. Turns out the FB.Login code was fired twice.
I suggest you write a log near the FB.Login and make sure you don't see it twice.
It seems that this is due to a bug in Unity3D specific to iOS 8. See here for details : http://fogbugz.unity3d.com/default.asp?692236_po26b9sb1uqlag7p
Here is a workaround to fix the problem in NGUI. Go to UICamera.cs and add the following line of code in the function public void ProcessTouches ()
MouseOrTouch touch = null;
if (input.phase == TouchPhase.Ended && !mTouches.TryGetValue(currentTouchID, out touch))
return;
just after this :
for (int i = 0; i < Input.touchCount; ++i)
{
Touch input = Input.GetTouch(i);
currentTouchID = allowMultiTouch ? input.fingerId : 1;
I'm getting this error when I press a button in a flash/air app that used to work in the AIR 3.2 SDK - now upgraded to the AIR 3.5 SDK. Any help much appreciated.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at seed_template_fla::MainTimeline/frame7()[seed_template_fla.MainTimeline::frame7:31]
at flash.display::MovieClip/gotoAndPlay()
at seed_template_fla::MainTimeline/gotoPage() [seed_template_fla.MainTimeline::frame1:20]
at seed_template_fla::MainTimeline/gotoRepro() [seed_template_fla.MainTimeline::frame1:12]
I'm creating an app for iPhone using Flash CS6 on Mac and exporting using the Air 3.5 SDK. I also have the AIR 3.5 runtime installed.
The app is very simple at the moment. It basically moves from frame to frame when you press a button using the gotoAndPlay(frameNr) function. There are some hexes on the frames that update an array of numbers when clicked. They are also toggled visible/not visible.
This used to work perfectly using the AIR 3.2 SDK, but I recently downloaded the AIR 3.5 SDK from adobe and added it through flash (Help>Manage Air SDK) and set it as the build target in File>Publish Settings>Target.
When I switch back to AIR 3.2 SDK, the app works perfectly again.
Also, when I upload the app to my iPhone 4S running IOS 5.1 using AIR 3.5 SDK, I just see a black screen with 5 loading dots flashing. This also works fine with AIR 3.2 SDK.
This is the code for frame 7
The last line is line 31.
stop();
techtitle.text = "Select Trait";
techdesc.text = "Spend points to change core stats and other special abilities";
points.visible = false;
techpoints.visible=false;
pointsbalance.text = myPoints.toString();
btn_tech.visible = false;
curTechSelected = null;
trace("set hexes invisible");
for (var j:int = 0; j <= 67; j++) {
if (hexStatusb[j] == 1) {
this["btn_hex_"+j+"b"].visible = false;
}
}
function onBtnHex37bClick(event:MouseEvent):void
{
techtitle.text = "tech1";
techdesc.text = "tech1 description"
techpoints.text = "-2";
points.visible = true;
techpoints.visible=true;
btn_tech.visible = true;
curTechSelected = btn_hex_37b;
curTechSelectedNr = 37;
curTechPoints = 2;
}
trace(this["btn_hex_37b"]);
btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);
OK - so, after trying out lots of things, I figured out why this is happening.
Solution: get rid of all TFL text objects when running AIR 3.5 SDK
It seems that the TFL Text library wasn't being loaded properly at runtime. Something crucial that I neglected to mention was that I was getting this warning message (similar here http://forums.adobe.com/thread/825637)
Content will not stream... The runtime shared libraries being preloaded are textLayout_1.0.0.05... TFLText
and this warning message in the output
Warning: Ignoring 'secure' attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml. The 'secure' attribute is only permitted in HTTPS and socket policy files.
Simply removing all TFLText objects and changing them to classic text makes the app work fine again.
#csomakk Great news. I have found the answer. You can publish in 3.5 and 3.6 and have your TLF Text too. I posted a write-up on my blog that shows exactly how to do it.
To get started: the error message states that something is null.. it means, that the program doesn't know, where to look for it. It can happen, when you didn't create the object (btn_hex_37b = new MovieClip()); or you haven't even created a variable for it.
on the given line (btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);) only btn_hex_37b can be null, because onBtnHex37bClick exists, and if it wouldn't, the program wouldn't compile.
The reason it came up when switching to AIR 3.5 is probably that it calls some creation functions in different order. Go to the line where you define the btn_hex_37b variable. Search for that functions calling.. Make sure, that btn_hex_37b is created before going to frame7.
Also, if its not a vital, to have onBtn_hex_37bClick, you can do the following:
if(btn_hex_37b){
btn_hex_37b.addEventListener(MouseEvent.CLICK, onBtnHex37bClick);
}
the if will check if btn_hex_37b is not null.
On the else method, you can give a timeouted method(but that is ugly), or give the eventlistener right after the creation of the object.
Hope this helped.
For Flash CS6, copy this swc:
/Applications/Adobe Flash CS6/Common/Configuration/ActionScript 3.0/libs/flash.swc
Into my Flash Builder project using these steps:
http://interactivesection.files.wordpress.com/2009/06/include_fl_packages_in_flex_builder-1.jpg
and then use this link
http://curtismorley.com/2013/03/05/app-used-to-work-with-air-3-2-or-3-4-doesnt-work-with-air-3-5-or-3-6/#comment-241102