Why Facebook profile picture request return null on iOS? - ios

Everything works perfect on android but when I try to get the profile picture on iOS devices. The image returns null. I checked the Facebook documentation for iOS 9 I have exactly the same plist as shown in documentation. When I run the app in console I see "FB is log in" message but the profile pic has not shown. Can anyone help?
void Awake()
{
instance = this;
FB.Init(SetInıt, OnHideUnity);
}
public void FbLogin()
{
// This is an event trigger when the button pressed.
List<string> permissions = new List<string>();
permissions.Add("public_profile");
FB.LogInWithReadPermissions(permissions, AuthcallBack);
}
void DealWithFbMenus(bool isLoggedIn)
{
// This function is called in SetInit func in Awake.
if(isLoggedIn)
{
fbButton.SetActive(false);
profilePicture.gameObject.SetActive(true);
loggedInPlayer = true;
//FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUserName);
FB.API("/me/picture?type=square&height=128&width=128", HttpMethod.GET, DisplayProfilePic);
}
else
fbButton.SetActive(true);
}
void DisplayProfilePic(IGraphResult result)
{
if(result.Texture != null)
{
profilePicture.sprite = Sprite.Create(result.Texture, new Rect(0,0, 128, 128), new Vector2());
}
}

It is a bug on Unity 5.2. It fixed on new version of Unity 5.3

Related

Flutter connectivity: Works on Android, but on iOS simulator when I can open webpages in Safari I have internet but the app says there is no internet?

I use this package: https://pub.dev/packages/connectivity_plus
I have a finished application that is working on Android but when I am testing it on iOS it shows that there is no internet. I can use and open pages in Safari so there is definitely one. But the following code returns false in iOS:
class InternetConnectivity with ChangeNotifier {
StreamSubscription<ConnectivityResult>? _subscription;
bool haveInternet = false;
void checkConnectivity() {
if (_subscription == null) {
_subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
bool res = result == ConnectivityResult.mobile || result == ConnectivityResult.wifi;
setHaveInternet = res;
});
}
}
set setHaveInternet(bool value) {
if (haveInternet != value) {
haveInternet = value;
notifyListeners();
}
}
}
I don't get any errors so I don't really know where to look for the problem.
On the screen where it checks that internet connection starts with this:
bool _haveInternet = true;
then in initState() I set the value of it:
#override
void initState() {
super.initState();
InternetConnectivity ? _internetConnectivity = InternetConnectivity();
setState(() {
_haveInternet = _internetConnectivity!.haveInternet;
});
After the initState() ran, the _haveInternet becomes false, so the connectivity_plus package returns false while normally it should be true.
Thanks in advance.
The package has a bug. According to documentation it should only affect iOS simulator. https://github.com/fluttercommunity/plus_plugins/issues/479
From package comments:
/// On iOS, the connectivity status might not update when WiFi
/// status changes, this is a known issue that only affects simulators.
/// For details see https://github.com/fluttercommunity/plus_plugins/issues/479.

xamarin push notification ios Page navigation not working when push notification click

I have azure push notification in Xamarin forms. when push notification received I need to open a page in my application. Its working fine in android. In iOS its not working when app is open. When app is in the background its working find in iOS.
This is my App Delegate code
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo,
Action<UIBackgroundFetchResult> completionHandler)
{
try
{
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
NSError error;
NSData notification = NSJsonSerialization.Serialize(userInfo["action"], NSJsonWritingOptions.PrettyPrinted, out error);
string notificationString = NSString.FromData(notification, NSStringEncoding.UTF8).ToString();
var NotificationObj = JsonConvert.DeserializeObject<NotificationData>(notificationString);
NotificationService.pushPageName = NotificationObj.Notification[0].PageName.ToString();
NotificationService.pushAppName = NotificationObj.AppName.ToString();
NotificationService.OpenPages = NotificationObj.Notification[0].OpenPage;
NotificationService.Notification = notificationString;
if (UIApplication.SharedApplication.ApplicationState.Equals(UIApplicationState.Active))
{
//App is in foreground. Act on it.
var application1 = new App(NotificationService.pushPageName, NotificationService.pushAppName, NotificationService.Notification);
LoadApplication(application1);
}
else
{
// var application1 = new App(NotificationService.pushPageName, NotificationService.pushAppName, NotificationService.Notification);
// LoadApplication(application1);
}
}
catch (Exception ex)
{
//LogInfo.ReportErrorInfo(ex.Message, ex.StackTrace, "AppDelegate-DidReceiveRemoteNotification");
}
}
after click push notification I need to open splash screen again.
This is App.cs Code
public App(string openPageName, string openAppName,string notification)
{
ServiceContainer.Resolve<IPushNotificationActionService>()
.ActionTriggered += NotificationActionTriggered;
InitMainPage(openPageName, openAppName, notification);
}
private void InitMainPage(string pageName,string appName,string notification)
{
ServiceContainer.Resolve<IPushNotificationActionService>()
.ActionTriggered += NotificationActionTriggered;
PushNotificationActionService.PushNotificationPageName = pageName ;
PushNotificationActionService.PushNotificationAppName = appName;
PushNotificationActionService.PushNotificationMessage = notification;
MainPage = new NavigationPage(new Splash(pageName));
}
All methods are calling and push notification data also loading correctly in iOS. But not navigating to Spalsh Screen. Anyone have an idea to resolve this please help.
If the app is running, we don't need to reload app with LoadApplication , we can directly send message to set MainPage in App.cs .
iOS
if (UIApplication.SharedApplication.ApplicationState.Equals(UIApplicationState.Active))
{
MessagingCenter.Send<object>(this,"Hi");
}
Forms
public App()
{
InitializeComponent();
MainPage = new MainPage();
MessagingCenter.Subscribe<object>(this, "Hi", (obj) => {
MainPage = new NavigationPage(new Splash(pageName));
});
}

Please point me in the correct direction to understand how to run in the background in iOS

I'm working on a fitness app (using Xamarin) and would like it to continue running in the background if the user switches to another app or pushes the side button to blank out the screen. I have looked at multiple tutorials, include this one https://robgibbens.com/backgrounding-with-xamarin-forms/, which seemed very promising. However, when running my app and switching to another application or blanking the screen, my app simply suspends. Hers is the iOS specific code that starts the background task:
public class IOSPlayWorkoutTask
{
nint _taskID;
CancellationTokenSource _cts;
Workout _workout;
public async Task Start()
{
_cts = new CancellationTokenSource();
_taskID = UIApplication.SharedApplication.BeginBackgroundTask("IOSPlayWorkoutTask", OnExpiration);
try
{
WorkoutPlayer.Shared.Workout = _workout;
await WorkoutPlayer.Shared.PlayWorkout(_cts.Token);
}
catch (OperationCanceledException)
{
}
finally
{
if (_cts.IsCancellationRequested)
{
//Device.BeginInvokeOnMainThread(
// () => MessagingCenter.Send(new CancelPlayingWorkoutMessage(), CancelPlayingWorkoutMessage.MessageText));
}
}
UIApplication.SharedApplication.EndBackgroundTask(_taskID);
}
public void Pause()
{
WorkoutPlayer.Shared.RequestPause();
_cts.Cancel();
Device.BeginInvokeOnMainThread(
() => MessagingCenter.Send(new PausedWorkoutMessage(), PausedWorkoutMessage.MessageText));
}
public void Stop()
{
_cts.Cancel();
Device.BeginInvokeOnMainThread(
() => MessagingCenter.Send(new FinishedWorkoutMessage(), FinishedWorkoutMessage.MessageText));
}
void OnExpiration()
{
_cts.Cancel();
}
public IOSPlayWorkoutTask(Workout w)
{
_workout = w;
}
}
The iOS app delegate registers to receive messages, one of which starts the task above. I know I must be missing something very basic. Any help would be greatly appreciated. I know this has to be possible based on my experience using other fitness apps like Couch to 5k.
Thanks #sushihangover and #Paulw11 for your input. Looks like the secret is adding a handler to BeginBackgroundTask that calls EndBackgroundTask. Not sure I understand fully at this point, but apparently this give iOS the impression that you are a "good citizen", but continues processing your task. Here is my code that works:
public async Task Start()
{
_cts = new CancellationTokenSource();
//_taskID = UIApplication.SharedApplication.BeginBackgroundTask("IOSPlayWorkoutTask", OnExpiration);
_taskID = UIApplication.SharedApplication.BeginBackgroundTask(() =>
{
Console.WriteLine("Guess my time is up");
UIApplication.SharedApplication.EndBackgroundTask(_taskID);
});
try
{
WorkoutPlayer.Shared.Workout = _workout;
await WorkoutPlayer.Shared.PlayWorkout(_cts.Token);
//finished = true;
}
catch (OperationCanceledException)
{
Console.WriteLine("OperationCanceledException");
//finished = true;
}
finally
{
if (_cts.IsCancellationRequested)
{
//Device.BeginInvokeOnMainThread(
// () => MessagingCenter.Send(new CancelPlayingWorkoutMessage(), CancelPlayingWorkoutMessage.MessageText));
}
}
UIApplication.SharedApplication.EndBackgroundTask(_taskID);
}

Facebook API in actionscript 3

Basically I am trying to connect to Facebook using actionscript 3.0. If I were to run the application in Facebook, and it is connected to Facebook, the stamp image would be added to the screen. The codes below are the functions used:
private var facebookAppID:String = "myappID";
private var fbLoggedIn:Boolean = false;
public function tryout() {
Facebook.init(facebookAppID, onInit);
FBConnect();
}
protected function onInit(result:Object, fail:Object):void {
if (result) { //already logged in because of existing session
fbLoggedIn = true;
} else {
fbLoggedIn = false;
}
}
public function FBConnect():void {
trace("in FBConnect");
if (fbLoggedIn)
{
showFbForm();
trace("success logged in");
}
else
{ // attempt to request for login
var opts:Object = {scope:"publish_stream, email"};
Facebook.login(onLogin, opts);
trace("failed logged in");
}
}
protected function onLogin(result:Object, fail:Object):void {
trace("in onLogin");
if (result) { //successfully logged in
fbLoggedIn = true;
showFbForm();
} else {
fbLoggedIn = false;
return;
}
}
protected function showFbForm():void {
addChild(stamp1);
stamp1.x = 0;
stamp1.y = 0;
trace("in showFBForm()");
}
The stamp1 should be displayed on the stage. However, nothing is displayed at all. I have been trying and researched but it still does not display.
I don't know if you're hiding your app ID or you just filled in MyAppID as your appID,
but if it's the second then it won't work because that appID does not exist. You need to find your appID in your facebook dashboard.
Since your code can't connect to the appID, it won't show any content because the content of "myAppID" is null.

BlackBerry application unistallation problem?

In my balckberry application i am using the Persistance,List and Threads to execute the code.
The code is given below:
enter code here
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run(){
CategoryListScreen.getInstance(
UiApplication.getUiApplication())
.setCategoryListContent();
}
});
public void setCategoryListContent() {
categoryList.delete(0);
CategoryListScreen categoryListScreen = CategoryListScreen
.getInstance(UiApplication.getUiApplication());
PersistentObject categoryListPersistObject = PersistentStore
.getPersistentObject(0x73c8d3592648fea5L);
PersistentObject datePersistObject = PersistentStore
.getPersistentObject(0xe453c1c0c14b9aebL);
categoryListPersistObject.setContents(Communicator.categoryDatas);
datePersistObject.setContents(new Date());
categoryListScreen.setCategoryListVector(new Vector());
categoryDataList = Communicator.categoryDatas;
System.out.println("-------------------- " + Communicator.categoryDatas.length);
for (int i = 0; i < Communicator.categoryDatas.length; i++) {
if (Communicator.categoryDatas[i] != null) {
if (Communicator.categoryDatas[i].getName() != null) {
categoryListScreen.getCategoryListVector().addElement(
Communicator.categoryDatas[i].getName());
}
}
}
testListCallback = new ListCallback();
categoryList.setCallback(testListCallback);
int i = categoryListScreen.getCategoryListVector().size();
categoryListScreen.getCategoryList().setSize(i);
System.out.println("---------------------->" + categoryListScreen.getCategoryListVector().size());
//
categoryListScreen.getCategoryList().setRowHeight(40);
// categoryListScreen.invalidate();
invalidate();
System.out.println("End.........................");
}
The application is Using the Threads to execute the persistance and also setting the size of the list.The application is running fine and exiting successfully.
But at the time of unistalling the application the device get being restarted and also after restarting the application ,there is no effect on the application.The application still remains there.
what is the problem in uinstalling the application which uses Threads,persistance and list?
why is it being restarted without any user confirmation or alert?
why is it not get being uninsall after restart?
please give the resolution for the given problem or any useful code snippet ,which would be appreciated.
Thanks,
Mishal Shah
Is this on a device simulator or a real device? As far as I know, if you reset the simulator, it loads back all the installed apps onto to simulator.

Resources