lundi 29 juin 2015

Firebase facebook login for ios (swift) - Use of unresolved indentifier 'FBSDKLoginManager'


I am just trying to run facebook login via Firebase in my ios app. I have done everything that is mentioned in Firebase`s ios (swift) guide [http://ift.tt/1BWVqou] but I am still facing compilation error:

Use of unresolved identifier 'FBSDKLoginManager'

If I am using:

let facebookLogin = FBSDKLoginManager()

Please note I have downloaded FBSKCoreKit, FBSLoginKit and FBSKShareKit (via cocoapods).

I have also updated my AppDelegate.swift like mentioned in the 7th step from guide above. I have also updated my ...-Bridging-Header.h file like:

#import <Firebase/Firebase.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>

I have also added mentioned frameworks:

libicucore.dylib, libc++.dylib, CFNetwork.framework, Security.framework, SystemConfiguration.framework

Could you please tell me, what I have missed? Thank you for any suggestions.

My pod file:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
use_frameworks!

target 'MyTarget' do

pod 'Alamofire', '~> 1.2'
pod 'AEXML'
pod 'AlecrimCoreData', '~> 3.0'
pod 'Firebase', '>= 2.3.2'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit' 

end

target 'MyProjectTests' do

end


Url Encoding of dictionary with AFNetworking in Objective-c


i have to send POST request in following format to the server:
Content Type: application/x-www-form-urlencoded
Form Key : data
Form Value :

[
 {
   "email" : "test@test.com",
   "password" : "test@test.com"     
 }
]

When i send request by this format in web rest client (Postman/Advance Rest Client),i got success in response.

So how can i send this type of response with AFNetworking?

My code for Objective-c is

NSDictionary *dictLogin = @{@"email":@"test@test.com",@"password":@"test@test.com"};
NSDictionary *dictReq = @{@"data":@[dictLogin]};
NSData *data = [NSJSONSerialization dataWithJSONObject:dictReq options:NSJSONWritingPrettyPrinted error:nil];
NSString *strReq = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager POST:@"http://test.php" parameters:dictReq success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

When i pass dictReq or str as AFNetworking parameter i got response of missing parameter/failure response from server

If it's not possible or hard with AFNetworking , NSUrlConnection/Request will also work

Thanks


Memory Leak and its solutions using weak declaration in Swift


I'm making a match-3 game using SpriteKit. Explanation: http://ift.tt/1wrZ5I3. Please refer to swm93's comment on page 4
This is a tutorial but it seems to have a memory leak in the code. Could anyone possibly download this swift project file and find what causes the memory leak and give possible solutions? The maker of this tutorial said that there is a memory leak in "handleSwipe(swap)" method and that we can fix it by adding "weak" to field declaration. I tried to write "weak var scene: GameScene?" but if I do, it says "scene is nil" even if I initialized it like this: "scene = GameScene(size: skView.bounds.size)" in "viewDidLoad()" function.
Below code is my "GameViewController.swift" and the rest of the classes can be downloaded through my link here.

import UIKit
import SpriteKit
import AVFoundation

class GameViewController: UIViewController {
    // The scene draws the tiles and cookie sprites, and handles swipes.
    var scene: GameScene!

    // The level contains the tiles, the cookies, and most of the gameplay logic.
    // Needs to be ! because it's not set in init() but in viewDidLoad().
    var level: Level!

    var movesLeft = 0
    var score = 0

    @IBOutlet weak var targetLabel: UILabel!
    @IBOutlet weak var movesLabel: UILabel!
    @IBOutlet weak var scoreLabel: UILabel!
    @IBOutlet weak var gameOverPanel: UIImageView!
    @IBOutlet weak var shuffleButton: UIButton!

    var tapGestureRecognizer: UITapGestureRecognizer!

    @IBAction func dismiss(sender: UIButton) {
        self.dismissViewControllerAnimated(true, completion: {})
    }

    lazy var backgroundMusic: AVAudioPlayer = {
        let url = NSBundle.mainBundle().URLForResource("Mining by Moonlight", withExtension: "mp3")
        let player = AVAudioPlayer(contentsOfURL: url, error: nil)
        player.numberOfLoops = -1
        return player
        }()

    override func prefersStatusBarHidden() -> Bool {
        return true
    }

    override func shouldAutorotate() -> Bool {
        return true
    }

    override func supportedInterfaceOrientations() -> Int {
        return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Configure the view.
        let skView = view as! SKView
        skView.multipleTouchEnabled = false

        // Create and configure the scene.
        scene = GameScene(size: skView.bounds.size)
        scene.scaleMode = .AspectFill

        // Load the level.
        level = Level(filename: "Level_1")
        scene.level = level
        scene.addTiles()
        scene.swipeHandler = handleSwipe

        // Hide the game over panel from the screen.
        gameOverPanel.hidden = true
        shuffleButton.hidden = true

        // Present the scene.
        skView.presentScene(scene)

        // Load and start background music.
        backgroundMusic.play()

        // Let's start the game!
        beginGame()
    }

    func beginGame() {
        movesLeft = level.maximumMoves
        score = 0
        updateLabels()

        level.resetComboMultiplier()

        scene.animateBeginGame() {
            self.shuffleButton.hidden = false
        }

        shuffle()
    }

    func shuffle() {
        // Delete the old cookie sprites, but not the tiles.
        scene.removeAllCookieSprites()

        // Fill up the level with new cookies, and create sprites for them.
        let newCookies = level.shuffle()
        scene.addSpritesForCookies(newCookies)
    }

    // This is the swipe handler. MyScene invokes this function whenever it
    // detects that the player performs a swipe.
    func handleSwipe(swap: Swap) {
        // While cookies are being matched and new cookies fall down to fill up
        // the holes, we don't want the player to tap on anything.
        view.userInteractionEnabled = false

        if level.isPossibleSwap(swap) {
            level.performSwap(swap)
            scene.animateSwap(swap, completion: handleMatches)
        } else {
            scene.animateInvalidSwap(swap) {
                self.view.userInteractionEnabled = true
            }
        }
    }

    // This is the main loop that removes any matching cookies and fills up the
    // holes with new cookies. While this happens, the user cannot interact with
    // the app.
    func handleMatches() {
        // Detect if there are any matches left.
        let chains = level.removeMatches()

        // If there are no more matches, then the player gets to move again.
        if chains.count == 0 {
            beginNextTurn()
            return
        }

        // First, remove any matches...
        scene.animateMatchedCookies(chains) {

            // Add the new scores to the total.
            for chain in chains {
                self.score += chain.score
            }
            self.updateLabels()

            // ...then shift down any cookies that have a hole below them...
            let columns = self.level.fillHoles()
            self.scene.animateFallingCookies(columns) {

                // ...and finally, add new cookies at the top.
                let columns = self.level.topUpCookies()
                self.scene.animateNewCookies(columns) {

                    // Keep repeating this cycle until there are no more matches.
                    self.handleMatches()
                }
            }
        }
    }

    func beginNextTurn() {
       level.resetComboMultiplier()
        level.detectPossibleSwaps()
        view.userInteractionEnabled = true
        decrementMoves()
    }

    func updateLabels() {
        targetLabel.text = String(format: "%ld", level.targetScore)
        movesLabel.text = String(format: "%ld", movesLeft)
        scoreLabel.text = String(format: "%ld", score)
    }

    func decrementMoves() {
        --movesLeft
        updateLabels()

        if score >= level.targetScore {
            gameOverPanel.image = UIImage(named: "LevelComplete")
            showGameOver()
        }
        else if movesLeft == 0 {
            gameOverPanel.image = UIImage(named: "GameOver")
            showGameOver()
        }
    }

    func showGameOver() {
        gameOverPanel.hidden = false
        scene.userInteractionEnabled = false
        shuffleButton.hidden = true

        scene.animateGameOver() {
            self.tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "hideGameOver")
            self.view.addGestureRecognizer(self.tapGestureRecognizer)
        }
    }

    func hideGameOver() {
        view.removeGestureRecognizer(tapGestureRecognizer)
        tapGestureRecognizer = nil

        gameOverPanel.hidden = true
        scene.userInteractionEnabled = true

        beginGame()
    }

    @IBAction func shuffleButtonPressed(AnyObject) {
        shuffle()

        // Pressing the shuffle button costs a move.
        decrementMoves()
    }
}


User tagging and hash tagging


I want to develop a functionality very similar to instagram and Facebook user tagging and hash tagging. How far I have come - 1. I can show suggestions when user enters @ and #.I do it in shouldchangecharacters in range funtion.

  1. I took a dictionary which contains tangle and location of tag in that textfield so I can show it in description in feeds.

Problems - I change color of Tag name but when I write just next to it that character color also changes. When user deletes characters from tagged username I want to delete it whole and location changes for tags so my dictionary become a complete waste. My code works only if user doesn't delete anything but keep writing characters and keep adding tags. Can anyone help me out? Please reply asap. I am stuck


XCode Storyboard Issue


I cant see the Labels, Button etc in the View or their constraints though the Labels and Button appears on the side of the storyboard. And when you run the program in the simulator you can see that they are there. The project from my colleague who uses XCode 6.3.1 and I am using XCode 6.3.2 and he doesn't have this issue. When he updated his to to the same version I have he had the same problem; so he went back to the previous version 6.3.1. Now the problem persisted on my device even when I removed the 6.3.2 and substitute it with 6.3.1

stackoverflow prevented me from uploading the images but I can send it by email to anyone to see the screen shots


Putting Pictures in DynamoDB


I was wondering if it was possible to put pictures into DynamoDB tables from an iOS device. If so I was wondering if someone could provide me with an example using the Swift language as I have no idea where to start.


Captive portal detection, popup implementation?


Based on hostapd, I m building a captive portal. - My Linux Machine provides a Wifi access. - iPad's and Android clients-tablets connect this Wifi.

Generally, any client OS check if a url is reachable, if not : client OS states it is captive, and displays a popup browser window. Popup is used for login, presentation or else.

Id like to display such a popup, to present my machine's service. But I dont get it. I ve avoided the net forward though. All connexions are redirected in the machine localhost website.

Why dont I get such a popup ? How to get it ? How/Where should I implement it on my localhost ?