Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion ignores the initial prompt, goes straight to system prompt #90

Closed
multinerd opened this issue Sep 21, 2017 · 7 comments
Closed
Assignees
Labels

Comments

@multinerd
Copy link

Using the sample project, ive added a NSMotionUsageDescription and changed the file ArekCellVMServiceProgrammatically.swift replaceing the line

return ArekLocationAlways(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)

with

return ArekMotion(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)

and the system prompt gets called on app launch. I havent looked into CoreMotion that much so im not sure if it can be called any other time.

Ill update if i find anything out.

@ennioma
Copy link
Owner

ennioma commented Sep 22, 2017

Hi @multinerd,

You can update ArekCellVMServiceProgrammatically as follow:

`import Foundation
import arek

class ArekCellVMServiceProgrammatically {
static private var permissions = [
["popupDataTitle": "Media Library Access - native", "allowButtonTitle": "Allow 👍🏼", "denyButtonTitle": "No! 👎🏼", "enableTitle": "Please!", "reEnableTitle": "Re-enable please!"],
["popupDataTitle": "Camera Access - PMAlertController", "allowButtonTitle": "Allow 👍🏼", "denyButtonTitle": "No! 👎🏼", "enableTitle": "Please!", "reEnableTitle": "Re-enable please!"],
["popupDataTitle": "Location Always Access - native", "allowButtonTitle": "Allow 👍🏼", "denyButtonTitle": "No! 👎🏼", "enableTitle": "Please!", "reEnableTitle": "Re-enable please!"],
["popupDataTitle": "Motion - PMAlertController", "allowButtonTitle": "Allow 👍🏼", "denyButtonTitle": "No! 👎🏼", "enableTitle": "Please!", "reEnableTitle": "Re-enable please!"],
]

static func numberOfVMs() -> Int {
    return self.permissions.count
}

static func buildVM(index: Int) -> ArekCellVM {
    let data = permissions[index]
    
    let configuration = ArekConfiguration(frequency: .OnceADay, presentInitialPopup: true, presentReEnablePopup: true)
    let initialPopupData = ArekPopupData(title: data["popupDataTitle"]!, message: data["enableTitle"]!, image: "", allowButtonTitle: data["allowButtonTitle"]!, denyButtonTitle: data["denyButtonTitle"]!, type: getPopuptType(index: index))
    let reenablePopupData = ArekPopupData(title: data["popupDataTitle"]!, message: data["reEnableTitle"]!, image: "", allowButtonTitle: data["allowButtonTitle"]!, denyButtonTitle: data["denyButtonTitle"]!, type: getPopuptType(index: index))
    
    let permission = getPermissionType(index: index, configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reenablePopupData)
    return ArekCellVM(permission: permission!, title: data["popupDataTitle"]!)
}

static private func getPopuptType(index: Int) -> ArekPopupType {
    switch index {
    case 0:
        return .native
    case 1:
        return .codeido
    case 2:
        return .native
    case 3:
        return .codeido
    default:
        return .native
    }
}

static private func getPermissionType(index: Int, configuration: ArekConfiguration, initialPopupData: ArekPopupData, reEnablePopupData: ArekPopupData) -> ArekPermissionProtocol? {
    
    switch index {
    case 0:
        return ArekMediaLibrary(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)
    case 1:
        return ArekCamera(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)
    case 2:
        return ArekLocationAlways(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)
    case 3:
        return ArekMotion(configuration: configuration, initialPopupData: initialPopupData, reEnablePopupData: reEnablePopupData)
    default:
        return nil
    }
}

}
`

As you can see I've just appended another permission for you. You have to consider that this doesn't work on simulator.

Let me know if it works for you!

@ennioma ennioma closed this as completed Sep 22, 2017
@ennioma ennioma reopened this Sep 22, 2017
@multinerd
Copy link
Author

multinerd commented Sep 22, 2017

Same thing on my side. it prompts for permission on app launch, so by the time i click the cell, i would have already burned my only ios request.

In other words, the framework is completely bypassed.

@ennioma
Copy link
Owner

ennioma commented Sep 25, 2017

Ok found it! Let me work on this and I'll let you know.

@ennioma ennioma self-assigned this Oct 15, 2017
@ennioma
Copy link
Owner

ennioma commented Oct 18, 2017

Hi @multinerd,
I think I've fixed this issue in #91, could you please check if the new logic from that branch works for you?

@multinerd
Copy link
Author

@ennioma I've moved over from the iOS project i was working on to a C# desktop version. Ill be able to test it this weekend and let you know.

@ennioma
Copy link
Owner

ennioma commented Oct 19, 2017

@multinerd In the meanwhile I've merged it to develop. So you can checkout it.

If everything is fine in the weekend I'll deliver another release.

@multinerd
Copy link
Author

Sorry, i lost track. The latest in the develop branch seems to be working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants